-
Notifications
You must be signed in to change notification settings - Fork 149
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
K8SPSMDB-1061: Refactor reconcileStatefulSet
#1386
Conversation
if cr.Spec.Sharding.Enabled && replset.ClusterRole != api.ClusterRoleConfigSvr && replset.Name == api.ConfigReplSetName { | ||
return reconcile.Result{}, errors.Errorf("%s is reserved name for config server replset", api.ConfigReplSetName) | ||
return "", errors.Errorf("%s is reserved name for config server replset", api.ConfigReplSetName) |
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.
Since you added AppStateNone
why don't you return that rather than this empty string?
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 value is ignored when an error is returned. I think it's better to not use const instead of an empty string because if AppStateNone
changes in the future, we would still want to have an empty string here
return reconcile.Result{}, errors.Wrap(err, "reconcile statefulsets") | ||
} | ||
|
||
err = r.stopMongosInCaseOfRestore(ctx, cr) |
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 put this inside of reconcileMongo
since it is related to actually reconciling mongos, and plus, less lines in our Reconcile
method.
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.
reconcileStatefulSet
reconcileStatefulSet
commit: 636aa82 |
https://perconadev.atlassian.net/browse/K8SPSMDB-1061
DESCRIPTION
Initially, I included it as part of a ticket, but later I found a better solution that didn't require refactoring. However, I believe that a small refactoring could still be beneficial for our code.
The main problem it aims to address is reducing the size of the
reconcileStatefulSet
andReconcile
methods for theReconcilePerconaServerMongoDB
.Changes in
pkg/controller/perconaservermongodb.go
:Reconcile
method code to a new method calledreconcileReplsets
getStatefulsetFromReplset
that returns a full statefulset based on the replset specChanges in
pkg/psmdb/statefulset.go
:StatefulSpec
functionreconcileStatefulSet
method to theStatefulSpec
functionpkg/psmdb/backup/agent.go
thereCHECKLIST
Jira
Needs Doc
) and QA (Needs QA
)?Tests
compare/*-oc.yml
)?Config/Logging/Testability