Skip to content

Commit c902b8a

Browse files
committed
Generate complete leader election record to resolve leader election issues with LeaseLocks
1 parent b19de7f commit c902b8a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

staging/src/k8s.io/client-go/tools/leaderelection/leaderelection.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,12 @@ func (le *LeaderElector) release() bool {
289289
if !le.IsLeader() {
290290
return true
291291
}
292+
now := metav1.Now()
292293
leaderElectionRecord := rl.LeaderElectionRecord{
293-
LeaderTransitions: le.observedRecord.LeaderTransitions,
294+
LeaderTransitions: le.observedRecord.LeaderTransitions,
295+
LeaseDurationSeconds: 1,
296+
RenewTime: now,
297+
AcquireTime: now,
294298
}
295299
if err := le.config.Lock.Update(context.TODO(), leaderElectionRecord); err != nil {
296300
klog.Errorf("Failed to release lock: %v", err)

0 commit comments

Comments
 (0)