mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #25748 from derekwaynecarr/hotloop_quota
Automatic merge from submit-queue ResourceQuota controller uses rate limiter to prevent hot-loops in error situations Have resource quota controller use a rate limited queue to prevent hot-looping in error situations.
This commit is contained in:
commit
b84730ba16
@ -62,7 +62,7 @@ type ResourceQuotaController struct {
|
|||||||
// Watches changes to all resource quota
|
// Watches changes to all resource quota
|
||||||
rqController *framework.Controller
|
rqController *framework.Controller
|
||||||
// ResourceQuota objects that need to be synchronized
|
// ResourceQuota objects that need to be synchronized
|
||||||
queue *workqueue.Type
|
queue workqueue.RateLimitingInterface
|
||||||
// To allow injection of syncUsage for testing.
|
// To allow injection of syncUsage for testing.
|
||||||
syncHandler func(key string) error
|
syncHandler func(key string) error
|
||||||
// function that controls full recalculation of quota usage
|
// function that controls full recalculation of quota usage
|
||||||
@ -77,7 +77,7 @@ func NewResourceQuotaController(options *ResourceQuotaControllerOptions) *Resour
|
|||||||
// build the resource quota controller
|
// build the resource quota controller
|
||||||
rq := &ResourceQuotaController{
|
rq := &ResourceQuotaController{
|
||||||
kubeClient: options.KubeClient,
|
kubeClient: options.KubeClient,
|
||||||
queue: workqueue.New(),
|
queue: workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()),
|
||||||
resyncPeriod: options.ResyncPeriod,
|
resyncPeriod: options.ResyncPeriod,
|
||||||
registry: options.Registry,
|
registry: options.Registry,
|
||||||
replenishmentControllers: []framework.ControllerInterface{},
|
replenishmentControllers: []framework.ControllerInterface{},
|
||||||
@ -170,10 +170,12 @@ func (rq *ResourceQuotaController) worker() {
|
|||||||
}
|
}
|
||||||
defer rq.queue.Done(key)
|
defer rq.queue.Done(key)
|
||||||
err := rq.syncHandler(key.(string))
|
err := rq.syncHandler(key.(string))
|
||||||
if err != nil {
|
if err == nil {
|
||||||
utilruntime.HandleError(err)
|
rq.queue.Forget(key)
|
||||||
rq.queue.Add(key)
|
return false
|
||||||
}
|
}
|
||||||
|
utilruntime.HandleError(err)
|
||||||
|
rq.queue.AddRateLimited(key)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
Loading…
Reference in New Issue
Block a user