Fix resource quota controller shutting down its worker threads

This commit is contained in:
derekwaynecarr 2016-05-10 15:59:34 -04:00
parent ff4a5e2068
commit 31970780cc

View File

@ -163,19 +163,24 @@ func (rq *ResourceQuotaController) enqueueResourceQuota(obj interface{}) {
// worker runs a worker thread that just dequeues items, processes them, and marks them done.
// It enforces that the syncHandler is never invoked concurrently with the same key.
func (rq *ResourceQuotaController) worker() {
workFunc := func() bool {
key, quit := rq.queue.Get()
if quit {
return true
}
defer rq.queue.Done(key)
err := rq.syncHandler(key.(string))
if err != nil {
utilruntime.HandleError(err)
rq.queue.Add(key)
}
return false
}
for {
func() {
key, quit := rq.queue.Get()
if quit {
return
}
defer rq.queue.Done(key)
err := rq.syncHandler(key.(string))
if err != nil {
utilruntime.HandleError(err)
rq.queue.Add(key)
}
}()
if quit := workFunc(); quit {
glog.Infof("resource quota controller worker shutting down")
return
}
}
}