Skip to content

Commit 77ee754

Browse files
authored
Merge pull request kubernetes#81540 from roycaihw/webhook-e2e-dial-timeout
Handle tcp dial timeout in webhook e2e test
2 parents 6f13032 + c8cd0bc commit 77ee754

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/e2e/apimachinery/webhook.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ var _ = SIGDescribe("AdmissionWebhook", func() {
243243
testSlowWebhookTimeoutNoError(f)
244244
slowWebhookCleanup()
245245

246-
ginkgo.By("Having no error when timeout is empty (defaulted to 10s in v1beta1)")
246+
ginkgo.By("Having no error when timeout is empty (defaulted to 10s in v1)")
247247
slowWebhookCleanup = registerSlowWebhook(f, f.UniqueName, context, &policyFail, nil)
248248
testSlowWebhookTimeoutNoError(f)
249249
slowWebhookCleanup()
@@ -1969,9 +1969,12 @@ func testSlowWebhookTimeoutFailEarly(f *framework.Framework) {
19691969
name := "e2e-test-slow-webhook-configmap"
19701970
_, err := client.CoreV1().ConfigMaps(f.Namespace.Name).Create(&v1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: name}})
19711971
framework.ExpectError(err, "create configmap in namespace %s should have timed-out reaching slow webhook", f.Namespace.Name)
1972-
expectedErrMsg := `/always-allow-delay-5s?timeout=1s: context deadline exceeded`
1973-
if !strings.Contains(err.Error(), expectedErrMsg) {
1974-
e2elog.Failf("expect error contains %q, got %q", expectedErrMsg, err.Error())
1972+
// http timeout message: context deadline exceeded
1973+
// dial timeout message: dial tcp {address}: i/o timeout
1974+
isTimeoutError := strings.Contains(err.Error(), `context deadline exceeded`) || strings.Contains(err.Error(), `timeout`)
1975+
isErrorQueryingWebhook := strings.Contains(err.Error(), `/always-allow-delay-5s?timeout=1s`)
1976+
if !isTimeoutError || !isErrorQueryingWebhook {
1977+
e2elog.Failf("expect an HTTP/dial timeout error querying the slow webhook, got: %q", err.Error())
19751978
}
19761979
}
19771980

0 commit comments

Comments
 (0)