Skip to content

Commit ba54a76

Browse files
authored
make backoff less aggressive (#287)
1 parent 1fdcc07 commit ba54a76

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ require (
1616
github.com/spf13/cast v1.8.0
1717
github.com/spf13/cobra v1.9.1
1818
github.com/spf13/pflag v1.0.6
19-
golang.org/x/time v0.11.0
2019
k8s.io/api v0.33.0
2120
k8s.io/apiextensions-apiserver v0.33.0
2221
k8s.io/apimachinery v0.33.0
@@ -87,6 +86,7 @@ require (
8786
golang.org/x/sys v0.32.0 // indirect
8887
golang.org/x/term v0.30.0 // indirect
8988
golang.org/x/text v0.23.0 // indirect
89+
golang.org/x/time v0.11.0 // indirect
9090
golang.org/x/tools v0.31.0 // indirect
9191
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
9292
google.golang.org/protobuf v1.36.5 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
143143
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
144144
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
145145
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
146-
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
147-
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
148146
github.com/spf13/cast v1.8.0 h1:gEN9K4b8Xws4EX0+a0reLmhq8moKn7ntRlQYgjPeCDk=
149147
github.com/spf13/cast v1.8.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
150148
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
@@ -263,8 +261,6 @@ sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
263261
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
264262
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc=
265263
sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps=
266-
sigs.k8s.io/structured-merge-diff/v6 v6.0.0 h1:KNyvHZ4ODhitmwNvjprMRBdppZHoDJQF3xlcELX8Qd4=
267-
sigs.k8s.io/structured-merge-diff/v6 v6.0.0/go.mod h1:GbAVeWiRqSnOZ+kOAZWugRTPF3M9ySS4W3tL++kxz3w=
268264
sigs.k8s.io/structured-merge-diff/v6 v6.1.0 h1:Aq+bzXrxvdbzihQtiZrDPbaNBvIo5+Uy31ZrLXgufv8=
269265
sigs.k8s.io/structured-merge-diff/v6 v6.1.0/go.mod h1:eHHiJVSr7sxSHSQm+ZPJoLNyJtH9FSrHrAGAU2touOk=
270266
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=

internal/backoff/backoff.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
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+
2229
func 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

Comments
 (0)