Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ require (
github.com/spf13/cast v1.8.0
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6
golang.org/x/time v0.11.0
k8s.io/api v0.33.0
k8s.io/apiextensions-apiserver v0.33.0
k8s.io/apimachinery v0.33.0
Expand Down Expand Up @@ -87,6 +86,7 @@ require (
golang.org/x/sys v0.32.0 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/text v0.23.0 // indirect
golang.org/x/time v0.11.0 // indirect
golang.org/x/tools v0.31.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cast v1.8.0 h1:gEN9K4b8Xws4EX0+a0reLmhq8moKn7ntRlQYgjPeCDk=
github.com/spf13/cast v1.8.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
Expand Down Expand Up @@ -263,8 +261,6 @@ sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc=
sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps=
sigs.k8s.io/structured-merge-diff/v6 v6.0.0 h1:KNyvHZ4ODhitmwNvjprMRBdppZHoDJQF3xlcELX8Qd4=
sigs.k8s.io/structured-merge-diff/v6 v6.0.0/go.mod h1:GbAVeWiRqSnOZ+kOAZWugRTPF3M9ySS4W3tL++kxz3w=
sigs.k8s.io/structured-merge-diff/v6 v6.1.0 h1:Aq+bzXrxvdbzihQtiZrDPbaNBvIo5+Uy31ZrLXgufv8=
sigs.k8s.io/structured-merge-diff/v6 v6.1.0/go.mod h1:eHHiJVSr7sxSHSQm+ZPJoLNyJtH9FSrHrAGAU2touOk=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
Expand Down
20 changes: 11 additions & 9 deletions internal/backoff/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"sync"
"time"

"golang.org/x/time/rate"
"k8s.io/client-go/util/workqueue"
)

Expand All @@ -19,18 +18,21 @@ type Backoff struct {
limiter workqueue.RateLimiter
}

/*
Returned backoff does
- 5 quick roundtrips (exponential, below 1s)
- then 15 roundtrips at 1s
- then 30 roundtrips at 2s
- then rounttrips at 10s
*/

func NewBackoff(maxDelay time.Duration) *Backoff {
return &Backoff{
activities: make(map[any]any),
// resulting per-item backoff is the maximum of a 120-times-100ms-then-maxDelay per-item limiter,
// and an overall 1-per-second-burst-50 bucket limiter;
// as a consequence, we have
// - a phase of 10 retries per second for the first 5 seconds
// - then a phase of 1 retry per second for the next 60 seconds
// - finally slow retries at the rate given by maxDelay
limiter: workqueue.NewMaxOfRateLimiter(
workqueue.NewItemFastSlowRateLimiter(100*time.Millisecond, maxDelay, 120),
&workqueue.BucketRateLimiter{Limiter: rate.NewLimiter(rate.Limit(1), 50)},
workqueue.NewItemExponentialFailureRateLimiter(50*time.Millisecond, 1*time.Second),
workqueue.NewItemFastSlowRateLimiter(0, 2*time.Second, 20),
workqueue.NewItemFastSlowRateLimiter(0, maxDelay, 20+30),
),
}
}
Expand Down