Skip to content

K8SPSMDB-1031: Fix live member calculation with external arbiter#2441

Open
egegunes wants to merge 2 commits into
mainfrom
K8SPSMDB-1031
Open

K8SPSMDB-1031: Fix live member calculation with external arbiter#2441
egegunes wants to merge 2 commits into
mainfrom
K8SPSMDB-1031

Conversation

@egegunes

@egegunes egegunes commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported MongoDB version?
  • Does the change support oldest and newest supported Kubernetes version?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 countLiveMembers helper and uses it from updateConfigMembers.
  • 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},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L 100-499 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants