From e41cbb752e6181350a2a56a69130b3ec2df5a4af Mon Sep 17 00:00:00 2001 From: YZ775 Date: Wed, 24 Apr 2024 04:28:09 +0000 Subject: [PATCH] DrainBackOffCount --- op/reboot.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/op/reboot.go b/op/reboot.go index 03817c8a..30e5b2df 100644 --- a/op/reboot.go +++ b/op/reboot.go @@ -16,7 +16,8 @@ import ( "k8s.io/client-go/kubernetes" ) -const drainBackOffBaseSeconds = 60 +const drainBackOffBaseSeconds = 300 +const drainBackOffMaxSeconds = 1200 type rebootDrainStartOp struct { finished bool @@ -571,7 +572,12 @@ 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++ - entry.DrainBackOffExpire = entry.LastTransitionTime.Add(time.Second * time.Duration(drainBackOffBaseSeconds+rand.Int63n(int64(drainBackOffBaseSeconds*entry.DrainBackOffCount)))) + backoffDuration := time.Second * time.Duration((1<<(entry.DrainBackOffCount-1))*drainBackOffBaseSeconds) + if backoffDuration > time.Second*drainBackOffMaxSeconds { + backoffDuration = time.Second * time.Duration(drainBackOffMaxSeconds+rand.Int63n(drainBackOffBaseSeconds)) + } + entry.DrainBackOffExpire = entry.LastTransitionTime.Add(backoffDuration) + err = inf.Storage().UpdateRebootsEntry(ctx, entry) if err != nil { return err