Skip to content

K8SPSMDB-723: Hidden replicaset members#1925

Merged
hors merged 6 commits intomainfrom
K8SPSMDB-723
May 26, 2025
Merged

K8SPSMDB-723: Hidden replicaset members#1925
hors merged 6 commits intomainfrom
K8SPSMDB-723

Conversation

@egegunes
Copy link
Copy Markdown
Contributor

@egegunes egegunes commented May 16, 2025

K8SPSMDB-723 Powered by Pull Request Badge

CHANGE DESCRIPTION

This PR makes it possible to deploy hidden replicaset members. Implementation is almost identical to non-voting members: Operator will create a separate statefulset for hidden members and properyly configure them in replset.

Hidden members are tested together with non-voting members in non-voting-and-hidden test.

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?

don't skip hidden in setVotes

fix physical restores with hidden members

e2e test

fix smart update
@egegunes egegunes added this to the v1.21.0 milestone May 16, 2025
@pull-request-size pull-request-size bot added the size/XXL 1000+ lines label May 16, 2025
@github-actions github-actions bot added the tests label May 16, 2025
@egegunes egegunes marked this pull request as ready for review May 20, 2025 15:42
Comment on lines +866 to +901
if h.LivenessProbe == nil {
h.LivenessProbe = new(LivenessProbeExtended)
}
if h.LivenessProbe.InitialDelaySeconds < 1 {
h.LivenessProbe.InitialDelaySeconds = rs.LivenessProbe.InitialDelaySeconds
}
if h.LivenessProbe.TimeoutSeconds < 1 {
h.LivenessProbe.TimeoutSeconds = rs.LivenessProbe.TimeoutSeconds
}
if h.LivenessProbe.PeriodSeconds < 1 {
h.LivenessProbe.PeriodSeconds = rs.LivenessProbe.PeriodSeconds
}
if h.LivenessProbe.FailureThreshold < 1 {
h.LivenessProbe.FailureThreshold = rs.LivenessProbe.FailureThreshold
}
if h.LivenessProbe.StartupDelaySeconds < 1 {
h.LivenessProbe.StartupDelaySeconds = rs.LivenessProbe.StartupDelaySeconds
}
if h.LivenessProbe.ProbeHandler.Exec == nil {
h.LivenessProbe.Probe.ProbeHandler.Exec = &corev1.ExecAction{
Command: []string{"/opt/percona/mongodb-healthcheck", "k8s", "liveness"},
}

if cr.TLSEnabled() {
h.LivenessProbe.Probe.ProbeHandler.Exec.Command = append(
h.LivenessProbe.Probe.ProbeHandler.Exec.Command,
"--ssl", "--sslInsecure", "--sslCAFile", "/etc/mongodb-ssl/ca.crt", "--sslPEMKeyFile", "/tmp/tls.pem",
)
}
}
startupDelaySecondsFlag := "--startupDelaySeconds"
if !h.LivenessProbe.CommandHas(startupDelaySecondsFlag) {
h.LivenessProbe.ProbeHandler.Exec.Command = append(
h.LivenessProbe.ProbeHandler.Exec.Command,
startupDelaySecondsFlag, strconv.Itoa(h.LivenessProbe.StartupDelaySeconds))
}
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.

optional: Given that this whole block is focused on liveness, maybe we could extract it to a function like the following:

func (h *HiddenSpec) setLivenessProbe(cr *PerconaServerMongoDB, rs *ReplsetSpec)

It is not that the current share is complicated or anything, but I think the extraction helps readability. Right now has too much detail.

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.

We can do something similar for the readiness probe.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case naming.ComponentNonVoting:
pdbspec = rs.NonVoting.PodDisruptionBudget
volumeSpec = rs.NonVoting.VolumeSpec
case naming.ComponentHidden:
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.

Given that we added a new case of replsets, I think it would be nice to have a new test case in our statefulset_test.go file, on the TestReconcileStatefulSet set. We have already covered these:

  • mongod
  • arbiter
  • non-voting

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +326 to +329
member.Tags = util.MapMerge(mongo.ReplsetTags{
naming.ComponentHidden: "true",
}, tags)
member.Priority = 0
Copy link
Copy Markdown
Contributor

@gkech gkech May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand by reading the documentation, the only configuration needed to setup a hidden replica set contains these 2 properties: 1) priority 0 and 2) the hidden tag equal to true. Correct?

https://www.mongodb.com/docs/manual/tutorial/configure-a-hidden-replica-set-member/#configuration-procedure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

gkech
gkech previously approved these changes May 22, 2025
@egegunes egegunes force-pushed the K8SPSMDB-723 branch 2 times, most recently from ba7f7d9 to 8350a68 Compare May 22, 2025 17:16
@JNKPercona
Copy link
Copy Markdown
Collaborator

Test name Status
arbiter passed
balancer passed
cross-site-sharded passed
custom-replset-name passed
custom-tls passed
custom-users-roles passed
custom-users-roles-sharded passed
data-at-rest-encryption passed
data-sharded passed
demand-backup passed
demand-backup-eks-credentials-irsa passed
demand-backup-fs passed
demand-backup-incremental passed
demand-backup-incremental-sharded passed
demand-backup-physical passed
demand-backup-physical-sharded passed
demand-backup-sharded passed
expose-sharded passed
finalizer passed
ignore-labels-annotations passed
init-deploy passed
ldap passed
ldap-tls passed
limits passed
liveness passed
mongod-major-upgrade passed
mongod-major-upgrade-sharded passed
monitoring-2-0 passed
monitoring-pmm3 passed
multi-cluster-service passed
multi-storage passed
non-voting-and-hidden passed
one-pod passed
operator-self-healing-chaos passed
pitr passed
pitr-physical passed
pitr-sharded passed
pitr-physical-backup-source passed
preinit-updates passed
pvc-resize passed
recover-no-primary passed
replset-overrides passed
rs-shard-migration passed
scaling passed
scheduled-backup passed
security-context passed
self-healing-chaos passed
service-per-pod passed
serviceless-external-nodes passed
smart-update passed
split-horizon passed
stable-resource-version passed
storage passed
tls-issue-cert-manager passed
upgrade passed
upgrade-consistency passed
upgrade-consistency-sharded-tls passed
upgrade-sharded passed
users passed
version-service passed
We run 60 out of 60

commit: 18ea724
image: perconalab/percona-server-mongodb-operator:PR-1925-18ea7246

@hors hors merged commit 7ed2565 into main May 26, 2025
3 checks passed
@hors hors deleted the K8SPSMDB-723 branch May 26, 2025 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants