Skip to content

K8SPXC-1805 make election params configurable - #2403

Merged
nmarukovich merged 30 commits into
mainfrom
K8SPXC-1805_make_election_params_configurable
Apr 29, 2026
Merged

K8SPXC-1805 make election params configurable#2403
nmarukovich merged 30 commits into
mainfrom
K8SPXC-1805_make_election_params_configurable

Conversation

@nmarukovich

Copy link
Copy Markdown
Contributor

CHANGE DESCRIPTION

Problem:
This PR exposes the following operator options through env vars:

PXCO_LEADER_ELECTION_LEASE_NAME - determines the name of the resource that leader election will use for holding the leader lock
PXCO_LEADER_ELECTION_LEASE_DURATION - duration that non-leader candidates will wait to force acquire leadership. This is measured against time of last observed ack
PXCO_LEADER_ELECTION_RENEW_DEADLINE - duration that the acting controlplane will retry refreshing leadership before giving up
PXCO_LEADER_ELECTION_RETRY_PERIOD - duration the LeaderElector clients should wait between tries of actions
PXCO_LEADER_ELECTION_ENABLED - disable/enable leader election
Suggested defaults:

PXCO_LEADER_ELECTION_LEASE_DURATION: 60s
PXCO_LEADER_ELECTION_RENEW_DEADLINE: 40s
PXCO_LEADER_ELECTION_RETRY_PERIOD: 10s
PXCO_LEADER_ELECTION_ENABLED: true
Additionally, all os.Getenv calls in cmd/manager/main.go are refactored to use github.com/kelseyhightower/envconfig with a single envConfig struct, consistent with the PG operator implementation (K8SPG-915).

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

  • 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 PXC version?
  • Does the change support oldest and newest supported Kubernetes version?

egegunes
egegunes previously approved these changes Mar 18, 2026
Comment thread cmd/manager/main.go Outdated
Comment on lines +269 to +271
LeaseDuration time.Duration `default:"60s" envconfig:"PXCO_LEADER_ELECTION_LEASE_DURATION"`
RenewDeadline time.Duration `default:"40s" envconfig:"PXCO_LEADER_ELECTION_RENEW_DEADLINE"`
RetryPeriod time.Duration `default:"10s" envconfig:"PXCO_LEADER_ELECTION_RETRY_PERIOD"`

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.

should we change these defaults to reflect the values in manifest files?

@egegunes egegunes added this to the v1.20.0 milestone Apr 2, 2026
@nmarukovich
nmarukovich requested a review from egegunes April 2, 2026 09:51
…b.com:percona/percona-xtradb-cluster-operator into K8SPXC-1805_make_election_params_configurable
Comment thread Makefile Outdated
# the 'latest' tag sometimes resolves to an older or incompatible version,
# leading to test or pipeline failures.
ENVTEST_K8S_VERSION = 1.34.1
ENVTEST_VERSION ?= release-0.23

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.

this looks like a duplicate?

@nmarukovich
nmarukovich requested a review from egegunes April 8, 2026 10:30
egegunes
egegunes previously approved these changes Apr 9, 2026
gkech
gkech previously approved these changes Apr 16, 2026
mayankshah1607
mayankshah1607 previously approved these changes Apr 16, 2026
@nmarukovich
nmarukovich dismissed stale reviews from egegunes, gkech, and mayankshah1607 via 0b90688 April 23, 2026 09:13
@JNKPercona

Copy link
Copy Markdown
Collaborator
Test Name Result Time
auto-tuning-8-0 passed 00:00:00
allocator-8-0 passed 00:00:00
allocator-8-4 passed 00:00:00
backup-storage-tls-8-0 passed 00:00:00
cross-site-8-0 passed 00:00:00
cross-site-proxysql-8-0 passed 00:00:00
cross-site-proxysql-8-4 passed 00:00:00
custom-users-8-0 passed 00:00:00
demand-backup-cloud-8-0 passed 00:00:00
demand-backup-cloud-8-4 passed 00:00:00
demand-backup-cloud-pxb-8-0 passed 00:55:13
demand-backup-encrypted-with-tls-5-7 passed 00:00:00
demand-backup-encrypted-with-tls-8-0 passed 00:00:00
demand-backup-encrypted-with-tls-8-4 passed 00:00:00
demand-backup-encrypted-with-tls-pxb-5-7 passed 00:00:00
demand-backup-encrypted-with-tls-pxb-8-0 passed 00:00:00
demand-backup-encrypted-with-tls-pxb-8-4 passed 00:00:00
demand-backup-8-0 passed 00:00:00
demand-backup-flow-control-8-0 passed 00:00:00
demand-backup-flow-control-8-4 passed 00:00:00
demand-backup-parallel-8-0 passed 00:00:00
demand-backup-parallel-8-4 passed 00:00:00
demand-backup-without-passwords-8-0 passed 00:00:00
demand-backup-without-passwords-8-4 passed 00:00:00
extra-pvc-8-0 passed 00:00:00
haproxy-5-7 passed 00:00:00
haproxy-8-0 passed 00:00:00
haproxy-8-4 passed 00:00:00
init-deploy-5-7 passed 00:00:00
init-deploy-8-0 passed 00:00:00
limits-8-0 passed 00:00:00
monitoring-2-0-8-0 passed 00:23:10
monitoring-pmm3-8-0 passed 00:00:00
monitoring-pmm3-8-4 passed 00:00:00
one-pod-5-7 passed 00:00:00
one-pod-8-0 passed 00:00:00
pitr-8-0 passed 00:48:12
pitr-8-4 passed 00:00:00
pitr-pxb-8-0 passed 00:47:02
pitr-pxb-8-4 passed 00:46:42
pitr-gap-errors-8-0 passed 00:00:00
pitr-gap-errors-8-4 passed 00:00:00
proxy-protocol-8-0 passed 00:00:00
proxy-switch-8-0 passed 00:00:00
proxysql-sidecar-res-limits-8-0 passed 00:00:00
proxysql-scheduler-8-0 passed 00:00:00
pvc-resize-5-7 passed 00:00:00
pvc-resize-8-0 passed 00:00:00
recreate-8-0 passed 00:00:00
restore-to-encrypted-cluster-8-0 passed 00:00:00
restore-to-encrypted-cluster-8-4 passed 00:00:00
restore-to-encrypted-cluster-pxb-8-0 passed 00:00:00
restore-to-encrypted-cluster-pxb-8-4 passed 00:00:00
scaling-proxysql-8-0 passed 00:00:00
scaling-8-0 passed 00:00:00
scheduled-backup-5-7 passed 00:00:00
scheduled-backup-8-0 passed 00:00:00
scheduled-backup-8-4 passed 00:00:00
security-context-8-0 passed 00:00:00
smart-update1-8-0 passed 00:00:00
smart-update1-8-4 passed 00:00:00
smart-update2-8-0 passed 00:00:00
smart-update2-8-4 passed 00:00:00
smart-update3-8-0 passed 00:00:00
sst-retry-limit-8-0 passed 00:00:00
sst-retry-limit-8-4 passed 00:00:00
storage-8-0 passed 00:00:00
tls-issue-cert-manager-ref-8-0 passed 00:00:00
tls-issue-cert-manager-8-0 passed 00:00:00
tls-issue-self-8-0 passed 00:14:10
upgrade-consistency-8-0 passed 00:00:00
upgrade-consistency-8-4 passed 00:00:00
upgrade-haproxy-5-7 passed 00:00:00
upgrade-haproxy-8-0 passed 00:00:00
upgrade-proxysql-5-7 passed 00:00:00
upgrade-proxysql-8-0 passed 00:00:00
users-5-7 passed 00:00:00
users-8-0 passed 00:00:00
users-scheduler-8-4 passed 00:29:05
validation-hook-8-0 passed 00:00:00
Summary Value
Tests Run 80/80
Job Duration 01:13:26
Total Test Time 04:23:38

commit: 90585fa
image: perconalab/percona-xtradb-cluster-operator:PR-2403-90585fa1

@nmarukovich
nmarukovich merged commit a26af3d into main Apr 29, 2026
15 checks passed
@nmarukovich
nmarukovich deleted the K8SPXC-1805_make_election_params_configurable branch April 29, 2026 14:16
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.

6 participants