From 44339e7e16d20ccd62d257ac28a05ea5716dde69 Mon Sep 17 00:00:00 2001 From: tnthornton <2375126+tnthornton@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:27:50 -0700 Subject: [PATCH] Remove references to controller-runtime/pkg/ratelimiter --- pkg/ratelimiter/default.go | 3 +-- pkg/ratelimiter/reconciler.go | 6 +++--- pkg/ratelimiter/reconciler_test.go | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/ratelimiter/default.go b/pkg/ratelimiter/default.go index cfe11154f..55b5ca3c0 100644 --- a/pkg/ratelimiter/default.go +++ b/pkg/ratelimiter/default.go @@ -23,7 +23,6 @@ import ( "golang.org/x/time/rate" "k8s.io/client-go/rest" "k8s.io/client-go/util/workqueue" - "sigs.k8s.io/controller-runtime/pkg/ratelimiter" ) // NewGlobal returns a token bucket rate limiter meant for limiting the number @@ -36,7 +35,7 @@ func NewGlobal(rps int) *workqueue.BucketRateLimiter { // NewController returns a rate limiter that takes the maximum delay between the // passed rate limiter and a per-item exponential backoff limiter. The // exponential backoff limiter has a base delay of 1s and a maximum of 60s. -func NewController() ratelimiter.RateLimiter { +func NewController() workqueue.RateLimiter { return workqueue.NewItemExponentialFailureRateLimiter(1*time.Second, 60*time.Second) } diff --git a/pkg/ratelimiter/reconciler.go b/pkg/ratelimiter/reconciler.go index cb95315c2..1acf681ce 100644 --- a/pkg/ratelimiter/reconciler.go +++ b/pkg/ratelimiter/reconciler.go @@ -21,7 +21,7 @@ import ( "sync" "time" - "sigs.k8s.io/controller-runtime/pkg/ratelimiter" + "k8s.io/client-go/util/workqueue" "sigs.k8s.io/controller-runtime/pkg/reconcile" ) @@ -31,7 +31,7 @@ import ( type Reconciler struct { name string inner reconcile.Reconciler - limit ratelimiter.RateLimiter + limit workqueue.RateLimiter limited map[string]struct{} limitedL sync.RWMutex @@ -40,7 +40,7 @@ type Reconciler struct { // NewReconciler wraps the supplied Reconciler, ensuring requests are passed to // it no more frequently than the supplied RateLimiter allows. Multiple uniquely // named Reconcilers can share the same RateLimiter. -func NewReconciler(name string, r reconcile.Reconciler, l ratelimiter.RateLimiter) *Reconciler { +func NewReconciler(name string, r reconcile.Reconciler, l workqueue.RateLimiter) *Reconciler { return &Reconciler{name: name, inner: r, limit: l, limited: make(map[string]struct{})} } diff --git a/pkg/ratelimiter/reconciler_test.go b/pkg/ratelimiter/reconciler_test.go index c8cdf5963..8ee018f7f 100644 --- a/pkg/ratelimiter/reconciler_test.go +++ b/pkg/ratelimiter/reconciler_test.go @@ -23,13 +23,13 @@ import ( "github.com/google/go-cmp/cmp" "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/ratelimiter" + "k8s.io/client-go/util/workqueue" "sigs.k8s.io/controller-runtime/pkg/reconcile" "github.com/crossplane/crossplane-runtime/pkg/test" ) -var _ ratelimiter.RateLimiter = &predictableRateLimiter{} +var _ workqueue.RateLimiter = &predictableRateLimiter{} type predictableRateLimiter struct{ d time.Duration }