Merge pull request #74989 from liggitt/webhook-test-namespace

Scope slow/failing webhook to test namespace
pull/564/head
Kubernetes Prow Robot 2019-03-06 03:26:26 -08:00 committed by GitHub
commit 3213a6d61f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -1481,7 +1481,17 @@ func registerSlowWebhook(f *framework.Framework, context *certContext, policy *v
namespace := f.Namespace.Name
configName := slowWebhookConfigName
_, err := client.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().Create(&v1beta1.ValidatingWebhookConfiguration{
// Add a unique label to the namespace
ns, err := client.CoreV1().Namespaces().Get(namespace, metav1.GetOptions{})
framework.ExpectNoError(err, "error getting namespace %s", namespace)
if ns.Labels == nil {
ns.Labels = map[string]string{}
}
ns.Labels[slowWebhookConfigName] = namespace
_, err = client.CoreV1().Namespaces().Update(ns)
framework.ExpectNoError(err, "error labeling namespace %s", namespace)
_, err = client.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().Create(&v1beta1.ValidatingWebhookConfiguration{
ObjectMeta: metav1.ObjectMeta{
Name: configName,
},
@ -1504,6 +1514,10 @@ func registerSlowWebhook(f *framework.Framework, context *certContext, policy *v
},
CABundle: context.signingCert,
},
// Scope the webhook to just this namespace
NamespaceSelector: &metav1.LabelSelector{
MatchLabels: ns.Labels,
},
FailurePolicy: policy,
TimeoutSeconds: timeout,
},