Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope slow/failing webhook to test namespace #74989

Merged
merged 1 commit into from Mar 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion test/e2e/apimachinery/webhook.go
Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand Down