Unverified Commit f7de67a1 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #64598 from MikeSpreitzer/fix-63608-b

Automatic merge from submit-queue (batch tested with PRs 65152, 65199, 65179, 64598, 65216). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Remove optimization from getWork in resourcequota/controller.go **What this PR does / why we need it**: 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. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #63608 **Special notes for your reviewer**: This is a simpler alternative to #64377 **Release note**: ```release-note NONE ```
parents 80da69b0 640d5b73
...@@ -642,6 +642,11 @@ func (e *quotaEvaluator) completeWork(ns string) { ...@@ -642,6 +642,11 @@ func (e *quotaEvaluator) completeWork(ns string) {
e.inProgress.Delete(ns) 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) { func (e *quotaEvaluator) getWork() (string, []*admissionWaiter, bool) {
uncastNS, shutdown := e.queue.Get() uncastNS, shutdown := e.queue.Get()
if shutdown { if shutdown {
...@@ -658,15 +663,8 @@ func (e *quotaEvaluator) getWork() (string, []*admissionWaiter, bool) { ...@@ -658,15 +663,8 @@ func (e *quotaEvaluator) getWork() (string, []*admissionWaiter, bool) {
work := e.work[ns] work := e.work[ns]
delete(e.work, ns) delete(e.work, ns)
delete(e.dirtyWork, ns) delete(e.dirtyWork, ns)
e.inProgress.Insert(ns)
if len(work) != 0 { return ns, work, false
e.inProgress.Insert(ns)
return ns, work, false
}
e.queue.Done(ns)
e.inProgress.Delete(ns)
return ns, []*admissionWaiter{}, false
} }
// prettyPrint formats a resource list for usage in errors // prettyPrint formats a resource list for usage in errors
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment