From 0bef5e4325e657ca9370c36138cc485dbe4b2614 Mon Sep 17 00:00:00 2001 From: Dan Mace Date: Mon, 15 Oct 2018 15:31:25 -0400 Subject: [PATCH] Make CreatePrivilegedPSPBinding reentrant Make CreatePrivilegedPSPBinding reentrant so tests using it (e.g. DNS) can be executed more than once against a cluster. Without this change, such tests will fail because the PSP already exists, short circuiting test setup. --- test/e2e/framework/psp_util.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/e2e/framework/psp_util.go b/test/e2e/framework/psp_util.go index cd281f00d54..30ba939095d 100644 --- a/test/e2e/framework/psp_util.go +++ b/test/e2e/framework/psp_util.go @@ -113,7 +113,9 @@ func CreatePrivilegedPSPBinding(f *Framework, namespace string) { psp := PrivilegedPSP(podSecurityPolicyPrivileged) psp, err = f.ClientSet.ExtensionsV1beta1().PodSecurityPolicies().Create(psp) - ExpectNoError(err, "Failed to create PSP %s", podSecurityPolicyPrivileged) + if !apierrs.IsAlreadyExists(err) { + ExpectNoError(err, "Failed to create PSP %s", podSecurityPolicyPrivileged) + } if IsRBACEnabled(f) { // Create the Role to bind it to the namespace. @@ -126,7 +128,9 @@ func CreatePrivilegedPSPBinding(f *Framework, namespace string) { Verbs: []string{"use"}, }}, }) - ExpectNoError(err, "Failed to create PSP role") + if !apierrs.IsAlreadyExists(err) { + ExpectNoError(err, "Failed to create PSP role") + } } })