K8SPSMDB-1031: Add the possibility to configure an external node as arbiter #2307
K8SPSMDB-1031: Add the possibility to configure an external node as arbiter #2307tariktunahanakan wants to merge 3 commits intopercona:mainfrom
Conversation
MongoDB does not allow setting tags on arbiter members
(replSetReconfig returns InvalidReplicaSetConfig). When an
external node is also an arbiter, FixMemberConfigs was
unconditionally attempting to apply the hardcoded
{"external":"true"} tag, causing the operator to enter a
permanent error reconciliation loop.
Add !member.ArbiterOnly guard so tag reconciliation is skipped
for arbiters, matching MongoDB's own constraint.
Fixes: operator sets cluster status to error with message
"Cannot set tags on arbiters" when externalNodes contains
an arbiter member.
Made-with: Cursor
|
|
| member := []ConfigMember(*m)[i] | ||
| c, ok := cm[member.Host] | ||
| if ok && c.Tags != nil && !reflect.DeepEqual(c.Tags, member.Tags) { | ||
| if ok && !member.ArbiterOnly && c.Tags != nil && !reflect.DeepEqual(c.Tags, member.Tags) { |
There was a problem hiding this comment.
this is not wrong actually but I'd like to skip adding tags in
as well which requires https://perconadev.atlassian.net/browse/K8SPSMDB-1031There was a problem hiding this comment.
Thanks for the feedback @egegunes!
Updated the PR to address the root cause in getConfigMemberForExternalNode:
- Added
arbiterOnly boolfield toExternalNodeAPI type (relates to K8SPSMDB-1031) - In
getConfigMemberForExternalNode, the{"external":"true"}tag is now only set when!extNode.ArbiterOnly, so arbiters never receive tags ArbiterOnlyis also propagated toConfigMemberfor downstream consistency- Added nil-guard in the custom tags loop for the case where an arbiter has user-defined tags in the CR
The fix inmongo.go(first commit) can be kept as defense-in-depth or dropped — up to you.
There was a problem hiding this comment.
thank you @tariktunahanakan.
i think the fix in mongo.go can be kept, yes.
…ters
Add `arbiterOnly` field to ExternalNode API type so users can explicitly
declare an external node as an arbiter in the CR spec.
In getConfigMemberForExternalNode, skip setting the {"external":"true"} tag
when the node is an arbiter — MongoDB does not allow any tags on arbiter
members and would reject the replSetReconfig with:
(InvalidReplicaSetConfig) Cannot set tags on arbiters.
Also propagate ArbiterOnly to the ConfigMember so downstream reconciliation
has full context about the member role.
Relates-to: K8SPSMDB-1031
Made-with: Cursor
| if !extNode.ArbiterOnly { | ||
| member.Tags = mongo.ReplsetTags{"external": "true"} | ||
| } |
There was a problem hiding this comment.
it'd be great to add unit tests for this function
| member := []ConfigMember(*m)[i] | ||
| c, ok := cm[member.Host] | ||
| if ok && c.Tags != nil && !reflect.DeepEqual(c.Tags, member.Tags) { | ||
| if ok && !member.ArbiterOnly && c.Tags != nil && !reflect.DeepEqual(c.Tags, member.Tags) { |
There was a problem hiding this comment.
thank you @tariktunahanakan.
i think the fix in mongo.go can be kept, yes.
commit: 8c85daa |
MongoDB does not allow setting tags on arbiter members (replSetReconfig returns InvalidReplicaSetConfig). When an external node is also an arbiter, FixMemberConfigs was unconditionally attempting to apply the hardcoded
{"external":"true"} tag, causing the operator to enter a permanent error reconciliation loop.
Add !member.ArbiterOnly guard so tag reconciliation is skipped for arbiters, matching MongoDB's own constraint.
Fixes: operator sets cluster status to error with message "Cannot set tags on arbiters" when externalNodes contains an arbiter member.
CHANGE DESCRIPTION
Problem:
Short explanation of the problem.
Cause:
Short explanation of the root cause of the issue if applicable.
Solution:
Short explanation of the solution we are providing with this PR.
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability