mirror of
https://github.com/fumiama/terasu-cloudflared.git
synced 2026-06-08 12:00:36 +08:00
TUN-7624: Fix flaky TestBackoffGracePeriod test in cloudflared
This commit is contained in:
@@ -91,10 +91,12 @@ func (b *BackoffHandler) Backoff(ctx context.Context) bool {
|
||||
|
||||
// Sets a grace period within which the the backoff timer is maintained. After the grace
|
||||
// period expires, the number of retries & backoff duration is reset.
|
||||
func (b *BackoffHandler) SetGracePeriod() {
|
||||
func (b *BackoffHandler) SetGracePeriod() time.Duration {
|
||||
maxTimeToWait := b.GetBaseTime() * 2 << (b.retries + 1)
|
||||
timeToWait := time.Duration(rand.Int63n(maxTimeToWait.Nanoseconds()))
|
||||
b.resetDeadline = Clock.Now().Add(timeToWait)
|
||||
|
||||
return timeToWait
|
||||
}
|
||||
|
||||
func (b BackoffHandler) GetBaseTime() time.Duration {
|
||||
|
||||
Reference in New Issue
Block a user