Skip to content

Commit

Permalink
Merge pull request kubernetes#127023 from aimuz/fix-lead
Browse files Browse the repository at this point in the history
leaderelection: replace deprecated wait.PollImmediateUntil with wait.PollUntilContextTimeout
  • Loading branch information
k8s-ci-robot authored Aug 30, 2024
2 parents c3cb89e + 3d2f498 commit 4cfdad0
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,13 @@ func (le *LeaderElector) renew(ctx context.Context) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
wait.Until(func() {
timeoutCtx, timeoutCancel := context.WithTimeout(ctx, le.config.RenewDeadline)
defer timeoutCancel()
err := wait.PollImmediateUntil(le.config.RetryPeriod, func() (bool, error) {
err := wait.PollUntilContextTimeout(ctx, le.config.RetryPeriod, le.config.RenewDeadline, true, func(ctx context.Context) (done bool, err error) {
if !le.config.Coordinated {
return le.tryAcquireOrRenew(timeoutCtx), nil
return le.tryAcquireOrRenew(ctx), nil
} else {
return le.tryCoordinatedRenew(timeoutCtx), nil
return le.tryCoordinatedRenew(ctx), nil
}
}, timeoutCtx.Done())

})
le.maybeReportTransition()
desc := le.config.Lock.Describe()
if err == nil {
Expand Down

0 comments on commit 4cfdad0

Please sign in to comment.