-
Notifications
You must be signed in to change notification settings - Fork 161
K8SPSMDB-1429: improve cluster status #2148
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
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.
Pull request overview
This PR improves the cluster status handling logic for sharded MongoDB clusters by restructuring conditional checks and refactoring the code that determines when a replica set should be added to a shard. The changes aim to make the condition evaluation more explicit and the code flow clearer.
Key Changes
- Restructured the conditional logic for shard addition to check prerequisites (mongos size, restore status, cluster role) separately from readiness conditions
- Extracted
rsStatusvariable to reduce redundant map lookups - Replaced manual boolean pointer creation with
ptr.To()helper for cleaner code
Comments suppressed due to low confidence (1)
pkg/controller/perconaservermongodb/mgo.go:235
- The first argument to 'errors.Wrap' is always nil.
return api.AppStateInit, nil, errors.Wrap(err, "failed to check running restore")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
egegunes
left a comment
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.
is it possible to add some unit tests for this?
@pooknull since we don't have any unit tests covering status code, i also need to add some tests in my PR. you don't need to add tests right now. we can add them in another PR after merging this. |
commit: fce4e0a |
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
https://perconadev.atlassian.net/browse/K8SPSMDB-1429
DESCRIPTION
Problem:
A PSMDB cluster can become ready before all replicasets have been added to the shard. This can cause issues when a restore is created at the same time as the cluster.
Cause:
Previously, the operator only checked whether all mongos pods were ready. If they weren’t, it still proceeded to set the cluster state based on other conditions.
Solution:
The operator should check separately whether sharding is enabled. If it is, the operator should keep the cluster in the initializing state until all replicasets are added to the shard.
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability