99 "sync"
1010 "time"
1111
12- "golang.org/x/time/rate"
1312 "k8s.io/client-go/util/workqueue"
1413)
1514
@@ -19,18 +18,21 @@ type Backoff struct {
1918 limiter workqueue.RateLimiter
2019}
2120
21+ /*
22+ Returned backoff does
23+ - 5 quick roundtrips (exponential, below 1s)
24+ - then 15 roundtrips at 1s
25+ - then 30 roundtrips at 2s
26+ - then rounttrips at 10s
27+ */
28+
2229func NewBackoff (maxDelay time.Duration ) * Backoff {
2330 return & Backoff {
2431 activities : make (map [any ]any ),
25- // resulting per-item backoff is the maximum of a 120-times-100ms-then-maxDelay per-item limiter,
26- // and an overall 1-per-second-burst-50 bucket limiter;
27- // as a consequence, we have
28- // - a phase of 10 retries per second for the first 5 seconds
29- // - then a phase of 1 retry per second for the next 60 seconds
30- // - finally slow retries at the rate given by maxDelay
3132 limiter : workqueue .NewMaxOfRateLimiter (
32- workqueue .NewItemFastSlowRateLimiter (100 * time .Millisecond , maxDelay , 120 ),
33- & workqueue.BucketRateLimiter {Limiter : rate .NewLimiter (rate .Limit (1 ), 50 )},
33+ workqueue .NewItemExponentialFailureRateLimiter (50 * time .Millisecond , 1 * time .Second ),
34+ workqueue .NewItemFastSlowRateLimiter (0 , 2 * time .Second , 20 ),
35+ workqueue .NewItemFastSlowRateLimiter (0 , maxDelay , 20 + 30 ),
3436 ),
3537 }
3638}
0 commit comments