Skip to content

Commit

Permalink
Merge pull request kubernetes#25748 from derekwaynecarr/hotloop_quota
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
k8s-merge-robot committed May 22, 2016
2 parents 1b78799 + 3075d85 commit b84730b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/controller/resourcequota/resource_quota_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{},
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b84730b

Please sign in to comment.