Skip to content

Commit 4cfdad0

Browse files
authored
Merge pull request kubernetes#127023 from aimuz/fix-lead
leaderelection: replace deprecated wait.PollImmediateUntil with wait.PollUntilContextTimeout
2 parents c3cb89e + 3d2f498 commit 4cfdad0

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,13 @@ func (le *LeaderElector) renew(ctx context.Context) {
277277
ctx, cancel := context.WithCancel(ctx)
278278
defer cancel()
279279
wait.Until(func() {
280-
timeoutCtx, timeoutCancel := context.WithTimeout(ctx, le.config.RenewDeadline)
281-
defer timeoutCancel()
282-
err := wait.PollImmediateUntil(le.config.RetryPeriod, func() (bool, error) {
280+
err := wait.PollUntilContextTimeout(ctx, le.config.RetryPeriod, le.config.RenewDeadline, true, func(ctx context.Context) (done bool, err error) {
283281
if !le.config.Coordinated {
284-
return le.tryAcquireOrRenew(timeoutCtx), nil
282+
return le.tryAcquireOrRenew(ctx), nil
285283
} else {
286-
return le.tryCoordinatedRenew(timeoutCtx), nil
284+
return le.tryCoordinatedRenew(ctx), nil
287285
}
288-
}, timeoutCtx.Done())
289-
286+
})
290287
le.maybeReportTransition()
291288
desc := le.config.Lock.Describe()
292289
if err == nil {

0 commit comments

Comments
 (0)