-
Notifications
You must be signed in to change notification settings - Fork 150
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-1249: Fix smart update for pods that are not member of replset #1781
Conversation
membersLive := 0 | ||
for _, member := range rsMembers { | ||
switch member.State { | ||
case mongo.MemberStatePrimary, mongo.MemberStateSecondary, mongo.MemberStateArbiter: |
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.
minor: Here we can also include the default case with a continue action.
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 there any practical difference?
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.
Only for better readability and clarity since unhandled cases are explicitly handled in a way (through the default). The behaviour remains the same!
podName, ok := tags["podName"] | ||
if !ok { | ||
continue | ||
} |
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.
We can write this in a more compact way if we want given that podName
is not used further, like this:
if podName, ok := tags["podName"]; ok {
rsMembers[podName] = api.ReplsetMemberStatus{
Name: member.Name,
State: member.State,
StateStr: member.StateStr,
}
}
it is also more consistent with the style we are using in the same function.
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.
commit: 19b115d |
CHANGE DESCRIPTION
Problem:
Operator can not finish smart update if update is triggered before replset is initialized.
Steps to reproduce:
cluster1-cfg-0
and creates users there. As of now, replset has only one member:cluster1-cfg-0
.cluster1-cfg-2
.cluster1-cfg-2
is not added to replset yet.Solution:
Maintain a map of members in cluster status and check if pod is a member of replset using this map. If pod is not a member, operator doesn't need to check if pod is primary and just update it.
Warning
Arbiter members won't show up in members map in status. It's because we use pod names as keys to map and we get this information from member tags in replset configuration but arbiters are not allowed to have tags.
CHECKLIST
Jira
Needs Doc
) and QA (Needs QA
)?Tests
compare/*-oc.yml
)?Config/Logging/Testability