-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
db upgrage: upgrade postgres 15 to postgres 16 #1415
base: master
Are you sure you want to change the base?
Conversation
@vh05, can you please improve the PR description? What are the changes, technical details on the env used, etc. |
sure |
ec79248
to
009642f
Compare
pkg/system/phase2_creating.go
Outdated
if r.isPostgresDBUpgradeReqd() { | ||
r.NooBaa.Status.BeforeUpgradeDbImage = r.NooBaa.Spec.DBImage | ||
r.NooBaa.Spec.DBImage = &options.DBImage | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this belongs here. GetDesiredDBImage
should be a general utility function, not a Reconciler method that modifies the object. It should also remain in system.go
Also, since this is the user input, you should generally not modify the values provided in the spec, such as r.NooBaa.Spec.DBImage
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
@@ -26,6 +26,8 @@ spec: | |||
- name: db | |||
image: NOOBAA_DB_IMAGE | |||
env: | |||
- name: POSTGRESQL_UPGRADE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only relevant for upgrades. when hardcoded here it will set the env for every new deployment as well.
The POSTGRES_UPGRADE
env should be set only when necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This is not needed anymore. The reconcile will detect upgrade status and flag will be set on the fly in memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that instead of deciding on upgrade and applying changes inside SetDesiredNooBaaDB
it will be more manageable, easy to follow, and less error-prone if you implement an UpgradeDB
function that will be performed before the DB reconciliation. This method will ensure that everything is upgraded correctly, and will only return nil if the reconciliation is ready to proceed.
Sure Danny. Let me check and do the changes |
The Postgres upgrade from 15 to 16 or any later versions can be done by adding the env variable named POSTGRES_UPGRADE = copy in the pg db pod. More about upgrade process is here: https://www.postgresql.org/docs/current/pgupgrade.html In our case, we achieve the upgrade by setting this env var in noobaa-db-pg STS. Once after upgrade is done, we have to remove the POSTGRES_UPGRADE env from the STS. Otherwise pg db pod fails to come up because the db pod check PG directory version against upgrade image version and exits if there is no upgrade required and POSTGRES_UPGRADE is still provided. To remove this env, we store the upgrade status in noobaa-core CR after the PG upgrade and refer the same status during db reconcile. If the upgrade is already done, we remove this env from desired sts status. This will help to upgrade the db smoothly Signed-off-by: Vinayak Hariharmath <[email protected]>
The Postgres upgrade from 15 to 16 or any later versions can be done by adding the env variable named
POSTGRES_UPGRADE = copy
in the pg db pod.More about upgrade process is here: https://www.postgresql.org/docs/current/pgupgrade.html
In our case, we achieve the upgrade by setting this env var in
noobaa-db-pg
STS.Once after upgrade is done, we have to remove the
POSTGRES_UPGRADE
env from the STS. Otherwise pg db pod fails to come up because the db pod check PG directory version against upgrade image version and exits if there is no upgrade required andPOSTGRES_UPGRADE
is still provided.To remove this env, we store the upgrade status in
noobaa-core
CR after the PG upgrade and refer the same status during db reconcile. If the upgrade is already done, we remove this env from desired sts status.This will help to upgrade the db smoothly