Skip to content

fix: disable leader election for single replica deployment - #2767

Open
tginer wants to merge 1 commit into
NVIDIA:mainfrom
tginer:main
Open

fix: disable leader election for single replica deployment#2767
tginer wants to merge 1 commit into
NVIDIA:mainfrom
tginer:main

Conversation

@tginer

@tginer tginer commented Aug 20, 2026

Copy link
Copy Markdown

This change avoids unnecessary leader-election overhead, removing currently lease renewal failures upon API downtime.

Description

Issue Observed

In single-node clusters, the gpu-operator enters a CrashLoopBackOff cycle after every node reboot due to leader election lease renewal failures during transient API outages. This adds unnecessary recovery time before ClusterPolicy is reconciled.

The --leader-elect flag is unconditionally hardcoded in the Helm Deployment template, even though the default deployment runs a single replica. With only one replica, leader election provides zero availability benefit — there is no second replica to fail over to. Instead, every transient kube-apiserver disruption (expected during SNO MCP reconciliation) triggers a fatal leader election loss → os.Exit(1) → CrashLoopBackOff.

Change proposal

This PR makes --leader-elect conditional on the replica count. It is only passed as an argument in case replica count is greater than 1.

As a precedent, the NVIDIA Network Operator - Node Feature Discovery already implemented this pattern in Mellanox/network-operator#2304

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Lint checks passing (make lint)
  • Generated assets in-sync (make validate-generated-assets)
  • Go mod artifacts in-sync (make validate-modules)
  • Test cases are added for new code paths

Testing

  • The operator controller image was built
  • API Server downtime was performed
  • Node reboot was performed

The logs demonstrate that from previous ~5 pod restarts, after the fix there is a single restart (caused by node rebot). Leader Election logs attempting to acquire the lease, failing to update lock, failing to renew the lease, leader election lost are no longer present.

This change avoids unnecessary leader-election overhead, removing currently lease renewal failures upon API downtime.

Signed-off-by: tginer <tginer@redhat.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@rahulait

Copy link
Copy Markdown
Contributor

/ok to test 0712179

nvidia.com/gpu-driver-upgrade-drain.skip: "true"
spec:
replicas: 1
replicas: {{ .Values.operator.replicas | default 1 }}

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 also needs to be added to values.yaml (maybe commented) so that users can find this.

args:
{{- if gt (int (.Values.operator.replicas | default 1)) 1 }}
- --leader-elect
{{- end }}

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.

What happens when two gpu-operator controllers come up at same time during upgrade (old controller and new controller)?

@tginer tginer Aug 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

In my opinion leader election is critical under multiple replicas deployed. With a single replica and a very brief overlap period, acting without a leader seems fairly safe.

The tests I performed resulted in:

  • The overlap window was between 10 - 15 seconds
  • Kubernetes reconciliation is idempotent
  • Kubernetes resourceVersion would prevent conflicts as pod B trying to update old version would result in a re-try and read new resourceVersion

Basically the two pods were briefly trying to do the same idempotent work and the old pod was terminated in a 10-15 second-window.

I replicated the idea implemented by NVIDIA in Mellanox/network-operator#2304 but the network operator AI agent bot also raised your concern in my identical PR in the NNO, see Mellanox/network-operator#3056

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants