-
Notifications
You must be signed in to change notification settings - Fork 110
Implemented data import from the old DB to the cluster on upgrade #1571
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
Conversation
986fbcb
to
5a92a76
Compare
pkg/system/db_reconciler.go
Outdated
r.Logger.Errorf("cnpg:: "+format, args...) | ||
} | ||
|
||
// wasClusterSpecChanged checks if any of the |
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.
typo?
@@ -514,6 +515,11 @@ func (r *Reconciler) SetDesiredCoreApp() error { | |||
podSpec.ServiceAccountName = "noobaa-core" | |||
coreImageChanged := false | |||
|
|||
oneReplica := int32(1) | |||
if r.CoreApp.Spec.Replicas != nil && *r.CoreApp.Spec.Replicas == 0 { |
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 would add a comment here explaining why replicas=0
5a92a76
to
304d4b9
Compare
- When upgrading from a deployment with an existing DB, provide the DB details in the cluster CR, to perform data import. - Upgrade flow is as follows: - If DB sts exist: - Stop core\endpoints pods - Create a cnpg cluster with import details in the CR - The cnpg operator will start the first instance and deploy an import job to import the data. After the import is completed, the second instance will started. - Wait for cluster to complete import and become Ready - Once ready scale down the noobaa-db-pg sts to 0 replicas. - The reconciliation will wait for the cluster to be ready, and a temp error is returned until it is. - The old sts is not deleted, to have it around for backup. In future versions we should cleanup all the leftovers. Signed-off-by: Danny Zaken <[email protected]>
304d4b9
to
25c557a
Compare
@@ -103,6 +103,31 @@ func RunInstall(cmd *cobra.Command, args []string) { | |||
util.KubeCreateSkipExisting(cnpgRes.WebhooksService) | |||
} | |||
|
|||
// RunInstall runs the CloudNativePG operator installation |
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.
// RunInstall runs the CloudNativePG operator installation | |
// RunUpgrade runs the CloudNativePG operator upgrade |
r.CNPGCluster.Spec.Bootstrap = &cnpgv1.BootstrapConfiguration{ | ||
InitDB: &cnpgv1.BootstrapInitDB{ | ||
Database: "nbcore", | ||
Owner: "noobaa", |
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.
Add other default properties explicitly (like collation, etc.)
func (r *Reconciler) reconcileClusterImport() error { | ||
|
||
// The bootstrap configuration should only be set for the CR creation. | ||
|
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.
regardless of this code only running in cluster creation flow. guard it to look at the noobaaDbStatus
// microservice type - import only the nbcore database | ||
Type: cnpgv1.MicroserviceSnapshotType, | ||
Databases: []string{ | ||
"nbcore", |
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.
remove "magic strings" and use consts\options instead
I added comments based on an online review with @jackyalbo and @liranmauda. Will handle them in a different PR |
Explain the changes
noobaa upgrade
command in noobaa cli, to install the necessary cnpg resources.Gaps
Testing Instructions:
noobaa upgrade
with a latest build of the CLI. this should install missing cnpg resources and update the noobaa CR to perform import