Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResourceQuota controller uses rate limiter to prevent hot-loops in error situations #25748

Merged
merged 1 commit into from
May 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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