Skip to content

Commit

Permalink
react to upstream fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k committed Jul 10, 2018
1 parent eb542f6 commit bbd3320
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
10 changes: 0 additions & 10 deletions pkg/cmd/server/kubernetes/master/master_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,7 @@ func TestCMServerDefaults(t *testing.T) {
ConcurrentGCSyncs: 20,
EnableGarbageCollector: true,
GCIgnoredResources: []componentconfig.GroupResource{
{Group: "extensions", Resource: "replicationcontrollers"},
{Group: "", Resource: "bindings"},
{Group: "", Resource: "componentstatuses"},
{Group: "", Resource: "events"},
{Group: "authentication.k8s.io", Resource: "tokenreviews"},
{Group: "authorization.k8s.io", Resource: "subjectaccessreviews"},
{Group: "authorization.k8s.io", Resource: "selfsubjectaccessreviews"},
{Group: "authorization.k8s.io", Resource: "localsubjectaccessreviews"},
{Group: "authorization.k8s.io", Resource: "selfsubjectrulesreviews"},
{Group: "apiregistration.k8s.io", Resource: "apiservices"},
{Group: "apiextensions.k8s.io", Resource: "customresourcedefinitions"},
},
},
HPAController: &cmoptions.HPAControllerOptions{
Expand Down
19 changes: 18 additions & 1 deletion pkg/quota/admission/clusterresourcequota/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"sync"
"time"

"k8s.io/apimachinery/pkg/runtime/schema"
utilwait "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle"
kapi "k8s.io/kubernetes/pkg/apis/core"
kinternalinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
kcorelisters "k8s.io/kubernetes/pkg/client/listers/core/internalversion"
Expand Down Expand Up @@ -94,7 +96,7 @@ func (q *clusterQuotaAdmission) Admit(a admission.Attributes) (err error) {

q.init.Do(func() {
clusterQuotaAccessor := newQuotaAccessor(q.clusterQuotaLister, q.namespaceLister, q.clusterQuotaClient, q.clusterQuotaMapper)
q.evaluator = resourcequota.NewQuotaEvaluator(clusterQuotaAccessor, install.DefaultIgnoredResources(), q.registry, q.lockAquisition, &resourcequotaapi.Configuration{}, numEvaluatorThreads, utilwait.NeverStop)
q.evaluator = resourcequota.NewQuotaEvaluator(clusterQuotaAccessor, ignoredResources, q.registry, q.lockAquisition, &resourcequotaapi.Configuration{}, numEvaluatorThreads, utilwait.NeverStop)
})

return q.evaluator.Evaluate(a)
Expand Down Expand Up @@ -174,3 +176,18 @@ type ByName []kapi.ResourceQuota
func (v ByName) Len() int { return len(v) }
func (v ByName) Swap(i, j int) { v[i], v[j] = v[j], v[i] }
func (v ByName) Less(i, j int) bool { return v[i].Name < v[j].Name }

// ignoredResources is the set of resources that clusterquota ignores. It's larger because we have to ignore requests
// that the namespace lifecycle plugin ignores. This is because of the need to have a matching namespace in order to be sure
// that the cache is current enough to have mapped the CRQ to the namespaces. Normal RQ doesn't have that requirement.
var ignoredResources = map[schema.GroupResource]struct{}{}

func init() {
for k, _ := range install.DefaultIgnoredResources() {
ignoredResources[k] = struct{}{}
}
for k, _ := range lifecycle.AccessReviewResources() {
ignoredResources[k] = struct{}{}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestOAuthServiceAccountClientEvent(t *testing.T) {
annotationPrefix: saoauth.OAuthRedirectModelAnnotationReferencePrefix + "1",
annotation: `{"kind":"foo","apiVersion":"oauth.openshift.io/v1","metadata":{"creationTimestamp":null},"reference":{"group":"foo","kind":"Route","name":"route1"}}`,
expectedEventReason: "NoSAOAuthRedirectURIs",
expectedEventMsg: `[no kind "foo" is registered for version "oauth.openshift.io/v1", system:serviceaccount:` + projectName + ":" + saName + " has no redirectURIs; set serviceaccounts.openshift.io/oauth-redirecturi.<some-value>=<redirect> or create a dynamic URI using serviceaccounts.openshift.io/oauth-redirectreference.<some-value>=<reference>]",
expectedEventMsg: `[no kind "foo" is registered for version "oauth.openshift.io/v1" in scheme "github.com/openshift/origin/pkg/serviceaccounts/oauthclient/oauthclientregistry.go:54", system:serviceaccount:` + projectName + ":" + saName + " has no redirectURIs; set serviceaccounts.openshift.io/oauth-redirecturi.<some-value>=<redirect> or create a dynamic URI using serviceaccounts.openshift.io/oauth-redirectreference.<some-value>=<reference>]",
numEvents: 1,
expectBadRequest: true,
},
Expand Down

0 comments on commit bbd3320

Please sign in to comment.