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:
k8s-merge-robot 2016-05-22 15:45:03 -07:00
commit b84730ba16

View File

@ -62,7 +62,7 @@ type ResourceQuotaController struct {
// Watches changes to all resource quota
rqController *framework.Controller
// ResourceQuota objects that need to be synchronized
queue *workqueue.Type
queue workqueue.RateLimitingInterface
// To allow injection of syncUsage for testing.
syncHandler func(key string) error
// function that controls full recalculation of quota usage
@ -77,7 +77,7 @@ func NewResourceQuotaController(options *ResourceQuotaControllerOptions) *Resour
// build the resource quota controller
rq := &ResourceQuotaController{
kubeClient: options.KubeClient,
queue: workqueue.New(),
queue: workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()),
resyncPeriod: options.ResyncPeriod,
registry: options.Registry,
replenishmentControllers: []framework.ControllerInterface{},
@ -170,10 +170,12 @@ func (rq *ResourceQuotaController) worker() {
}
defer rq.queue.Done(key)
err := rq.syncHandler(key.(string))
if err != nil {
utilruntime.HandleError(err)
rq.queue.Add(key)
if err == nil {
rq.queue.Forget(key)
return false
}
utilruntime.HandleError(err)
rq.queue.AddRateLimited(key)
return false
}
for {