Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --Currently when using it adds as one of the limiters. This does not work as intended because there is no immediate sleep following the call to the limiter as seen in which does work correctly. The issue with the in its current usage is there is no forget nor a sleep immediately following the call so if is called thousands of times in a row, the timeout grows very quickly with no max. For example, if a clusters has 10k secrets and those are all enqueued using the the will end up with a 16 min wait before the tail end of objects can be enqueued and processed. I would expect some max backoff to take affect. This can be seen at
/sig api-machinery
/cc /triage accepted
it possible to set maxWaitingTime for BucketRateLimiter? when r.Limiter.Reserve().Delay() maxWaitingTime, the return of BucketRateLimiter When() is maxWaitingTime. defined is 1000ms / r.limit * MAXQPS(5000) this issue example (r.tokens = 100, r.limit = 10), if call When() times, the tail end of the object is enqueued waiting for 8.33 min. i'm not sure how to set the value of MAXQPS please help review it
The fix merged to close this issue does not fix the underlying issue with the DefaultControllerRateLimiter. The bucket is not being used correctly so this does not work as intended, please read my issue description again as to what is actually happening.
is another fix needed to solve this issue?
A token bucket rate limiter will only refill at the defined rate. If enough requeues are , it will take a long time for the refill rate to clear the queue. If a max wait is introduced, then requeues will be inserted into the queue faster than the refill rate of the token bucket rate limiter. A max wait will violate the token bucket rate limiter and we want token bucket rate limiting behavior.

Discussion:
limiter.Forget(item) } } <ins> // WithMaxWaitRateLimiter have maxDelay which avoids waiting too long type WithMaxWaitRateLimiter struct { limiter  RateLimiter maxDelay time.Duration } func NewWithMaxWaitRateLimiter(limiter RateLimiter, maxDelay time.Duration) RateLimiter { return &WithMaxWaitRateLimiter{limiter: limiter, maxDelay: maxDelay} } func (w WithMaxWaitRateLimiter) When(item interface{}) time.Duration { delay := w.limiter.When(item) if delay > w.maxDelay { return w.maxDelay } return delay } func (w WithMaxWaitRateLimiter) Forget(item interface{}) { w.limiter.Forget(item) } func (w WithMaxWaitRateLimiter) NumRequeues(item interface{}) int { return w.limiter.NumRequeues(item) } </ins>

} } <ins> func TestWithMaxWaitRateLimiter(t *testing.T) { limiter := NewWithMaxWaitRateLimiter(DefaultControllerRateLimiter(), 500*time.Second) for i := 0; i < 100; i++ { if e, a := 5*time.Millisecond, limiter.When(i); e != a { t.Errorf("expected %v, got %v", e, a) } } for i := 100; i < 5100; i++ { if e, a := 500*time.Second, limiter.When(i); e < a { t.Errorf("expected %v, got %v", e, a) } } for i := 5100; i < 5200; i++ { if e, a := 500*time.Second, limiter.When(i); e != a { t.Errorf("expected %v, got %v", e, a) } } } </ins>