-
Notifications
You must be signed in to change notification settings - Fork 161
K8SPSMDB-1451: Wait until primary elected after rs initialization #2149
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| out := strings.Trim(stdout.String(), "\n") | ||
| if out != "true" { | ||
| return errors.New("is not the writable primary") |
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.
| return errors.New("is not the writable primary") | |
| return errors.New(pod.Name+" is not the writable primary") |
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.
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 replica set initialization process by replacing a blind 5-second wait after rs.initiate with an intelligent backoff retry mechanism that polls for primary election. The change makes the initialization process more reliable by actively checking when the primary is elected rather than assuming 5 seconds is always sufficient.
- Replaces fixed 5-second sleep with a backoff retry mechanism that actively checks for primary election
- Uses MongoDB's
hellocommand to verify the node is a writable primary - Adds exponential backoff with 5 retry steps and configurable timing parameters
💡 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 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
commit: 65db8e0 |
CHANGE DESCRIPTION
Problem:
Operator blindly waits for 5 seconds after running
rs.initiate.Solution:
Check if primary is elected with backoff retry.
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability