Merge pull request #124588 from jiuker/patch-2

fix: Hang when canceling leader election information
This commit is contained in:
Kubernetes Prow Robot 2024-05-08 19:30:36 -07:00 committed by GitHub
commit 7a6931b31c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -304,7 +304,9 @@ func (le *LeaderElector) release() bool {
RenewTime: now,
AcquireTime: now,
}
if err := le.config.Lock.Update(context.TODO(), leaderElectionRecord); err != nil {
timeoutCtx, timeoutCancel := context.WithTimeout(context.Background(), le.config.RenewDeadline)
defer timeoutCancel()
if err := le.config.Lock.Update(timeoutCtx, leaderElectionRecord); err != nil {
klog.Errorf("Failed to release lock: %v", err)
return false
}