From 57cb563be571599798325ad525075c0d63eef7c1 Mon Sep 17 00:00:00 2001 From: Andrew Stucki Date: Fri, 12 Apr 2024 12:59:58 -0400 Subject: [PATCH] Fix exponential backoff for api.LifetimeWatcher (#26383) * Fix exponential backoff for api.LifetimeWatcher * Add changelog entry --- api/lifetime_watcher.go | 7 +++++-- changelog/26383.txt | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelog/26383.txt diff --git a/api/lifetime_watcher.go b/api/lifetime_watcher.go index 5c060e5a15..4507e4462f 100644 --- a/api/lifetime_watcher.go +++ b/api/lifetime_watcher.go @@ -349,8 +349,11 @@ func (r *LifetimeWatcher) doRenewWithOptions(tokenMode bool, nonRenewable bool, if errorBackoff == nil { sleepDuration = r.calculateSleepDuration(remainingLeaseDuration, priorDuration) - } else if errorBackoff.NextBackOff() == backoff.Stop { - return err + } else { + sleepDuration = errorBackoff.NextBackOff() + if sleepDuration == backoff.Stop { + return err + } } // remainingLeaseDuration becomes the priorDuration for the next loop diff --git a/changelog/26383.txt b/changelog/26383.txt new file mode 100644 index 0000000000..8b675a9ef4 --- /dev/null +++ b/changelog/26383.txt @@ -0,0 +1,3 @@ +```release-note:bug +api: fixed a bug where LifetimeWatcher routines weren't respecting exponential backoff in the presence of unexpected errors +```