mirror of https://github.com/k3s-io/k3s
Merge pull request #22445 from derekwaynecarr/quota_replenish_perf
Auto commit by PR queue botpull/6/head
commit
005c67a1ef
|
@ -285,7 +285,14 @@ func (rq *ResourceQuotaController) syncResourceQuota(resourceQuota api.ResourceQ
|
|||
|
||||
// replenishQuota is a replenishment function invoked by a controller to notify that a quota should be recalculated
|
||||
func (rq *ResourceQuotaController) replenishQuota(groupKind unversioned.GroupKind, namespace string, object runtime.Object) {
|
||||
// TODO: make this support targeted replenishment to a specific kind, right now it does a full replenish
|
||||
// check if the quota controller can evaluate this kind, if not, ignore it altogether...
|
||||
evaluators := rq.registry.Evaluators()
|
||||
evaluator, found := evaluators[groupKind]
|
||||
if !found {
|
||||
return
|
||||
}
|
||||
|
||||
// check if this namespace even has a quota...
|
||||
indexKey := &api.ResourceQuota{}
|
||||
indexKey.Namespace = namespace
|
||||
resourceQuotas, err := rq.rqIndexer.Index("namespace", indexKey)
|
||||
|
@ -295,8 +302,15 @@ func (rq *ResourceQuotaController) replenishQuota(groupKind unversioned.GroupKin
|
|||
if len(resourceQuotas) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// only queue those quotas that are tracking a resource associated with this kind.
|
||||
matchedResources := evaluator.MatchesResources()
|
||||
for i := range resourceQuotas {
|
||||
resourceQuota := resourceQuotas[i].(*api.ResourceQuota)
|
||||
resourceQuotaResources := quota.ResourceNames(resourceQuota.Status.Hard)
|
||||
if len(quota.Intersection(matchedResources, resourceQuotaResources)) > 0 {
|
||||
// TODO: make this support targeted replenishment to a specific kind, right now it does a full recalc on that quota.
|
||||
rq.enqueueResourceQuota(resourceQuota)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue