Skip to content

Actual lease duration is ignored in LeaderElector.TryAcquireOrRenew #1640

@andredasilvapinto

Description

@andredasilvapinto

Describe the bug
LeaderElector.TryAcquireOrRenew uses the lease duration from the local configuration, instead of the Kubernetes object, assuming that the two values are the same.

This might not be true during graceful step downs, as libraries like the one for Golang set the lease duration to 1 second as a way to signal the leader has stepped down. C# clients would ignore this and still wait for the entire pre-configured duration of the lease before trying to acquire the lease.

This behaviour also differs from the Golang library, which uses the lease duration from the actual Kubernetes object.

Kubernetes C# SDK Client Version
14.0.2

Server Kubernetes Version
1.30.13

Dotnet Runtime Version
net8

To Reproduce
Create a lease and change its duration to 1s

Expected behavior
Non-leader C# clients should try to take the lease

Where do you run your app with Kubernetes SDK (please complete the following information):

  • OS: Linux
  • Environment: Container
  • Cloud: AWS and on-prem

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions