Merge pull request #31909 from derekwaynecarr/ns-ignore-bindings

Automatic merge from submit-queue

Ignore v1 bindings in namespace controller deletion

Fixes https://github.com/kubernetes/kubernetes/issues/31735

Ideally, in the long run, we can let clients built from discovery (and not requiring all of swagger) to know the verbs.

/cc @lavalamp
pull/6/head
Kubernetes Submit Queue 2016-09-01 16:26:18 -07:00 committed by GitHub
commit 25ef0edfe1
1 changed files with 18 additions and 1 deletions

View File

@ -63,13 +63,30 @@ func NewNamespaceController(
groupVersionResources []unversioned.GroupVersionResource,
resyncPeriod time.Duration,
finalizerToken api.FinalizerName) *NamespaceController {
// the namespace deletion code looks at the discovery document to enumerate the set of resources on the server.
// it then finds all namespaced resources, and in response to namespace deletion, will call delete on all of them.
// unfortunately, the discovery information does not include the list of supported verbs/methods. if the namespace
// controller calls LIST/DELETECOLLECTION for a resource, it will get a 405 error from the server and cache that that was the case.
// we found in practice though that some auth engines when encountering paths they don't know about may return a 50x.
// until we have verbs, we pre-populate resources that do not support list or delete for well-known apis rather than
// probing the server once in order to be told no.
opCache := operationNotSupportedCache{}
ignoredGroupVersionResources := []unversioned.GroupVersionResource{
{Group: "", Version: "v1", Resource: "bindings"},
}
for _, ignoredGroupVersionResource := range ignoredGroupVersionResources {
opCache[operationKey{op: operationDeleteCollection, gvr: ignoredGroupVersionResource}] = true
opCache[operationKey{op: operationList, gvr: ignoredGroupVersionResource}] = true
}
// create the controller so we can inject the enqueue function
namespaceController := &NamespaceController{
kubeClient: kubeClient,
clientPool: clientPool,
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "namespace"),
groupVersionResources: groupVersionResources,
opCache: operationNotSupportedCache{},
opCache: opCache,
finalizerToken: finalizerToken,
}