Skip to content

Commit 7f51bee

Browse files
committed
Fix hanging webhook error checking
1 parent bfaea07 commit 7f51bee

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/e2e/apimachinery/webhook.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,17 @@ func testWebhook(f *framework.Framework) {
729729
pod = hangingPod(f)
730730
_, err = client.CoreV1().Pods(f.Namespace.Name).Create(pod)
731731
framework.ExpectError(err, "create pod %s in namespace %s should have caused webhook to hang", pod.Name, f.Namespace.Name)
732-
expectedTimeoutErr := "request did not complete within"
733-
if !strings.Contains(err.Error(), expectedTimeoutErr) {
734-
e2elog.Failf("expect timeout error %q, got %q", expectedTimeoutErr, err.Error())
732+
// ensure the error is webhook-related, not client-side
733+
if !strings.Contains(err.Error(), "webhook") {
734+
e2elog.Failf("expect error %q, got %q", "webhook", err.Error())
735+
}
736+
// ensure the error is a timeout
737+
if !strings.Contains(err.Error(), "deadline") {
738+
e2elog.Failf("expect error %q, got %q", "deadline", err.Error())
739+
}
740+
// ensure the pod was not actually created
741+
if _, err := client.CoreV1().Pods(f.Namespace.Name).Get(pod.Name, metav1.GetOptions{}); !errors.IsNotFound(err) {
742+
e2elog.Failf("expect notfound error looking for rejected pod, got %v", err)
735743
}
736744

737745
ginkgo.By("create a configmap that should be denied by the webhook")

0 commit comments

Comments
 (0)