Skip to content

Commit

Permalink
fixup! DrainBackOffCount
Browse files Browse the repository at this point in the history
  • Loading branch information
YZ775 committed Apr 26, 2024
1 parent d70ab25 commit 893252d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions op/reboot.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,11 @@ func drainBackOff(ctx context.Context, inf cke.Infrastructure, entry *cke.Reboot
entry.Status = cke.RebootStatusQueued
entry.LastTransitionTime = time.Now().Truncate(time.Second).UTC()
entry.DrainBackOffCount++
backoffDuration := time.Second * time.Duration((1<<(entry.DrainBackOffCount-1))*drainBackOffBaseSeconds+rand.Int63n(drainBackOffBaseSeconds))
if backoffDuration > time.Second*drainBackOffMaxSeconds {
backoffDuration = time.Second * time.Duration(drainBackOffMaxSeconds+rand.Int63n(drainBackOffBaseSeconds))
backoffSeconds := (1 << (entry.DrainBackOffCount - 1)) * drainBackOffBaseSeconds
if backoffSeconds > drainBackOffMaxSeconds {
backoffSeconds = drainBackOffMaxSeconds
}
entry.DrainBackOffExpire = entry.LastTransitionTime.Add(backoffDuration)
entry.DrainBackOffExpire = entry.LastTransitionTime.Add(time.Second * time.Duration(backoffSeconds+rand.Intn(drainBackOffBaseSeconds)))

err = inf.Storage().UpdateRebootsEntry(ctx, entry)
if err != nil {
Expand Down

0 comments on commit 893252d

Please sign in to comment.