K8SPSMDB-1031: Fix live member calculation with external arbiter#2441
Open
egegunes wants to merge 2 commits into
Open
K8SPSMDB-1031: Fix live member calculation with external arbiter#2441egegunes wants to merge 2 commits into
egegunes wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes replset “live member” counting when an external arbiter is present (arbiters can’t be tagged, so the prior logic could incorrectly include external arbiters and misreport readiness).
Changes:
- Refactors live-member counting into a dedicated
countLiveMembershelper and uses it fromupdateConfigMembers. - Adds detection to skip external arbiters by matching config member host against
rs.ExternalNodes. - Adds unit tests covering live-member counting across primary/secondary/arbiter and external member scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/controller/perconaservermongodb/mgo.go | Extracts and updates live-member counting; introduces external-arbiter detection helper. |
| pkg/controller/perconaservermongodb/mgo_test.go | Adds unit tests for live-member counting behavior (including external member/arbiter cases). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+590
to
602
| func isExternalArbiter(cm mongo.ConfigMember, rs *api.ReplsetSpec) bool { | ||
| for _, extNode := range rs.ExternalNodes { | ||
| if !extNode.ArbiterOnly { | ||
| continue | ||
| } | ||
|
|
||
| if cm.Host == extNode.HostPort() { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| return false | ||
| } |
| }}, | ||
| rs: &api.ReplsetSpec{ | ||
| ExternalNodes: []*api.ExternalNode{ | ||
| {Host: "arbiter.example.com", Port: 27017, ArbiterOnly: true}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGE DESCRIPTION
Problem:
Arbiters can't have tags and this makes our live member calculation fail.
Solution:
Detect external arbiters by comparing their host and port and skip.
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability