From 39cfacd5fa6a7317a4c9f8658a1753812cc48bc0 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 11 Jun 2019 12:41:21 +0200 Subject: [PATCH] Backoff.Linear: panic when InitialBackoff > MaxBackoff this probably means there's a configuration issue. Since this struct is mainly set manually from code, I think it is okay to panic here. --- common/retry/retry.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/retry/retry.go b/common/retry/retry.go index 3189c4c97..38e2ba88d 100644 --- a/common/retry/retry.go +++ b/common/retry/retry.go @@ -94,6 +94,9 @@ type Backoff struct { // n = n * Multiplier. // the first value of n is InitialBackoff. n is maxed by MaxBackoff. func (lb *Backoff) Linear() time.Duration { + if lb.InitialBackoff > lb.MaxBackoff { + panic("InitialBackoff > MaxBackoff, did you forgot setting the seconds ?") + } wait := lb.InitialBackoff lb.InitialBackoff = time.Duration(lb.Multiplier * float64(lb.InitialBackoff)) if lb.MaxBackoff != 0 && lb.InitialBackoff > lb.MaxBackoff {