csharp icon indicating copy to clipboard operation
csharp copied to clipboard

Actual lease duration is ignored in LeaderElector.TryAcquireOrRenew

Open andredasilvapinto opened this issue 5 months ago • 7 comments

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

andredasilvapinto avatar Jul 18 '25 08:07 andredasilvapinto