-
Notifications
You must be signed in to change notification settings - Fork 488
ARO-26557: Fix etcd bootstrap race when replicas join after quorum #8425
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package etcd | ||
|
|
||
| // etcdRaftQuorumSize returns the minimum number of voting members that must be | ||
| // present for a Raft quorum for a cluster of clusterSize members. | ||
| func etcdRaftQuorumSize(clusterSize int) int { | ||
| if clusterSize <= 0 { | ||
| return 0 | ||
| } | ||
| return clusterSize/2 + 1 | ||
| } | ||
|
|
||
| // resetMemberStragglerJoinQuorumMet returns true when the number of members | ||
| // reported by etcdctl member list is already sufficient for the cluster to have | ||
| // raft quorum for an expected cluster of expectedClusterSize, and the cluster | ||
| // is not already at the expected size (so dynamic member add is appropriate). | ||
| func resetMemberStragglerJoinQuorumMet(memberCount, expectedClusterSize int) bool { | ||
| if expectedClusterSize <= 0 { | ||
| return false | ||
| } | ||
| return memberCount >= etcdRaftQuorumSize(expectedClusterSize) && memberCount < expectedClusterSize | ||
| } |
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.
grep "${HOSTNAME}"is a substring/regex match across the member list.grep "${HOSTNAME}"matches any line containing HOSTNAME, and treats it as a regex. For etcd member names sharing prefixes (e.g.etcd-1would also match a line foretcd-10/etcd-11), this can pick up the wrong row and yield a bogusMEMBER_ID(or a multi-line value that breaks the subsequentetcdctl member remove). Today HyperShift caps etcd at a small replica count so the collision is unlikely in practice, but since this line is being modified it’s cheap to harden.Two safer options:
-w simple, the member name is field 3):awk -F, -v name="${HOSTNAME}" '$3 == name { print $1 }'grep -F -w -- "${HOSTNAME}"to disable regex and require a whole-word match (note:-wstill treats-as a word boundary, so prefer the awk form for full safety).♻️ Proposed change
📝 Committable suggestion
🤖 Prompt for AI Agents