@@ -7,8 +7,10 @@ import (
7
7
"sync"
8
8
"time"
9
9
10
+ "k8s.io/apimachinery/pkg/runtime/schema"
10
11
utilwait "k8s.io/apimachinery/pkg/util/wait"
11
12
"k8s.io/apiserver/pkg/admission"
13
+ "k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle"
12
14
kapi "k8s.io/kubernetes/pkg/apis/core"
13
15
kinternalinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
14
16
kcorelisters "k8s.io/kubernetes/pkg/client/listers/core/internalversion"
@@ -94,7 +96,7 @@ func (q *clusterQuotaAdmission) Admit(a admission.Attributes) (err error) {
94
96
95
97
q .init .Do (func () {
96
98
clusterQuotaAccessor := newQuotaAccessor (q .clusterQuotaLister , q .namespaceLister , q .clusterQuotaClient , q .clusterQuotaMapper )
97
- q .evaluator = resourcequota .NewQuotaEvaluator (clusterQuotaAccessor , install . DefaultIgnoredResources () , q .registry , q .lockAquisition , & resourcequotaapi.Configuration {}, numEvaluatorThreads , utilwait .NeverStop )
99
+ q .evaluator = resourcequota .NewQuotaEvaluator (clusterQuotaAccessor , ignoredResources , q .registry , q .lockAquisition , & resourcequotaapi.Configuration {}, numEvaluatorThreads , utilwait .NeverStop )
98
100
})
99
101
100
102
return q .evaluator .Evaluate (a )
@@ -174,3 +176,18 @@ type ByName []kapi.ResourceQuota
174
176
func (v ByName ) Len () int { return len (v ) }
175
177
func (v ByName ) Swap (i , j int ) { v [i ], v [j ] = v [j ], v [i ] }
176
178
func (v ByName ) Less (i , j int ) bool { return v [i ].Name < v [j ].Name }
179
+
180
+ // ignoredResources is the set of resources that clusterquota ignores. It's larger because we have to ignore requests
181
+ // that the namespace lifecycle plugin ignores. This is because of the need to have a matching namespace in order to be sure
182
+ // that the cache is current enough to have mapped the CRQ to the namespaces. Normal RQ doesn't have that requirement.
183
+ var ignoredResources = map [schema.GroupResource ]struct {}{}
184
+
185
+ func init () {
186
+ for k , _ := range install .DefaultIgnoredResources () {
187
+ ignoredResources [k ] = struct {}{}
188
+ }
189
+ for k , _ := range lifecycle .AccessReviewResources () {
190
+ ignoredResources [k ] = struct {}{}
191
+ }
192
+
193
+ }
0 commit comments