From 640d5b73635b6d5b5990ae193fbf93a69be5e373 Mon Sep 17 00:00:00 2001 From: Mike Spreitzer Date: Thu, 31 May 2018 22:43:54 -0700 Subject: [PATCH] Remove optimization from getWork in resourcequota/controller.go This change simplifies the code in plugin/pkg/admission/resourcequota/controller.go by removing the optimization in getWork that required the caller to NOT call completeWork if getWork returns the empty list of work. BTW, the caller was not obeying that requirement; now the caller's behavior (which is unchanged) is right. Fixes #63608 --- plugin/pkg/admission/resourcequota/controller.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plugin/pkg/admission/resourcequota/controller.go b/plugin/pkg/admission/resourcequota/controller.go index 0f254365880..72f6773926e 100644 --- a/plugin/pkg/admission/resourcequota/controller.go +++ b/plugin/pkg/admission/resourcequota/controller.go @@ -583,6 +583,11 @@ func (e *quotaEvaluator) completeWork(ns string) { e.inProgress.Delete(ns) } +// getWork returns a namespace, a list of work items in that +// namespace, and a shutdown boolean. If not shutdown then the return +// must eventually be followed by a call on completeWork for the +// returned namespace (regardless of whether the work item list is +// empty). func (e *quotaEvaluator) getWork() (string, []*admissionWaiter, bool) { uncastNS, shutdown := e.queue.Get() if shutdown { @@ -599,15 +604,8 @@ func (e *quotaEvaluator) getWork() (string, []*admissionWaiter, bool) { work := e.work[ns] delete(e.work, ns) delete(e.dirtyWork, ns) - - if len(work) != 0 { - e.inProgress.Insert(ns) - return ns, work, false - } - - e.queue.Done(ns) - e.inProgress.Delete(ns) - return ns, []*admissionWaiter{}, false + e.inProgress.Insert(ns) + return ns, work, false } // prettyPrint formats a resource list for usage in errors