Skip to content

Commit 9bbe96e

Browse files
authored
Merge pull request #14 from munnerz/exp-comments
Add extra comments to exponential backoff code
2 parents 0c52580 + d1acb7e commit 9bbe96e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

manager/manager.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,17 @@ func (m *Manager) ManageVolume(volumeID string) error {
488488

489489
if meta.NextIssuanceTime == nil || m.clock.Now().After(*meta.NextIssuanceTime) {
490490
wait.ExponentialBackoffWithContext(ctx, wait.Backoff{
491+
// 2s is the 'base' amount of time for the backoff
491492
Duration: time.Second * 2,
493+
// We multiple the 'duration' by 2.0 if the attempt fails/errors
492494
Factor: 2.0,
495+
// Add a jitter of +/- 1s (0.5 of the 'duration')
493496
Jitter: 0.5,
494-
// Set this to the maximum int value to avoid resetting the exponential backoff
495-
// timer early.
496-
// This will mean that once the back-off hits 1 minute, we will constantly retry once
497-
// per minute rather than resetting back to `Duration` (2s).
497+
// 'Steps' controls what the maximum number of backoff attempts is before we
498+
// reset back to the 'base duration'. Set this to the MaxInt32, as we never want to
499+
// reset this unless we get a successful attempt.
498500
Steps: math.MaxInt32,
501+
// The maximum time between calls will be 1 minute
499502
Cap: time.Minute,
500503
}, func() (bool, error) {
501504
log.Info("Triggering new issuance")

0 commit comments

Comments
 (0)