Skip to content

K8SPXC-1805 make election params configurable#2403

Open
nmarukovich wants to merge 23 commits intomainfrom
K8SPXC-1805_make_election_params_configurable
Open

K8SPXC-1805 make election params configurable#2403
nmarukovich wants to merge 23 commits intomainfrom
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 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
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
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