mirror of https://github.com/k3s-io/k3s
Improve quota controller performance by eliminating unneeded list calls
parent
d08a722647
commit
f2f65fe9c4
|
@ -270,6 +270,10 @@ func (rq *ResourceQuotaController) syncResourceQuota(resourceQuota api.ResourceQ
|
|||
newUsage := api.ResourceList{}
|
||||
usageStatsOptions := quota.UsageStatsOptions{Namespace: resourceQuota.Namespace, Scopes: resourceQuota.Spec.Scopes}
|
||||
for _, evaluator := range evaluators {
|
||||
// only trigger the evaluator if it matches a resource in the quota, otherwise, skip calculating anything
|
||||
if intersection := quota.Intersection(evaluator.MatchesResources(), matchedResources); len(intersection) == 0 {
|
||||
continue
|
||||
}
|
||||
stats, err := evaluator.UsageStats(usageStatsOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -122,12 +122,7 @@ func TestSyncResourceQuota(t *testing.T) {
|
|||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
expectedActionSet := sets.NewString(
|
||||
strings.Join([]string{"list", "replicationcontrollers", ""}, "-"),
|
||||
strings.Join([]string{"list", "services", ""}, "-"),
|
||||
strings.Join([]string{"list", "pods", ""}, "-"),
|
||||
strings.Join([]string{"list", "resourcequotas", ""}, "-"),
|
||||
strings.Join([]string{"list", "secrets", ""}, "-"),
|
||||
strings.Join([]string{"list", "persistentvolumeclaims", ""}, "-"),
|
||||
strings.Join([]string{"update", "resourcequotas", "status"}, "-"),
|
||||
)
|
||||
actionSet := sets.NewString()
|
||||
|
@ -213,12 +208,7 @@ func TestSyncResourceQuotaSpecChange(t *testing.T) {
|
|||
}
|
||||
|
||||
expectedActionSet := sets.NewString(
|
||||
strings.Join([]string{"list", "replicationcontrollers", ""}, "-"),
|
||||
strings.Join([]string{"list", "services", ""}, "-"),
|
||||
strings.Join([]string{"list", "pods", ""}, "-"),
|
||||
strings.Join([]string{"list", "resourcequotas", ""}, "-"),
|
||||
strings.Join([]string{"list", "secrets", ""}, "-"),
|
||||
strings.Join([]string{"list", "persistentvolumeclaims", ""}, "-"),
|
||||
strings.Join([]string{"update", "resourcequotas", "status"}, "-"),
|
||||
)
|
||||
actionSet := sets.NewString()
|
||||
|
@ -293,12 +283,7 @@ func TestSyncResourceQuotaNoChange(t *testing.T) {
|
|||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
expectedActionSet := sets.NewString(
|
||||
strings.Join([]string{"list", "replicationcontrollers", ""}, "-"),
|
||||
strings.Join([]string{"list", "services", ""}, "-"),
|
||||
strings.Join([]string{"list", "pods", ""}, "-"),
|
||||
strings.Join([]string{"list", "resourcequotas", ""}, "-"),
|
||||
strings.Join([]string{"list", "secrets", ""}, "-"),
|
||||
strings.Join([]string{"list", "persistentvolumeclaims", ""}, "-"),
|
||||
)
|
||||
actionSet := sets.NewString()
|
||||
for _, action := range kubeClient.Actions() {
|
||||
|
|
Loading…
Reference in New Issue