From 007dc76f1fd3b810d7b906cef5083de4f94db228 Mon Sep 17 00:00:00 2001 From: Mikko Ylinen Date: Wed, 26 Apr 2023 10:57:30 +0300 Subject: [PATCH] envtest: set default webhook options for polling Similar to how it's done for the CRD installation, set default webhook options for timeout/poll interval values. This avoids getting MaxTime=0 which changes its behaviour when moving from k8s deprecated wait.PollImmediate() to wait.PollUntilContextTimeout(). Signed-off-by: Mikko Ylinen --- pkg/envtest/webhook.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/envtest/webhook.go b/pkg/envtest/webhook.go index 49d8773588..0e5c3635ff 100644 --- a/pkg/envtest/webhook.go +++ b/pkg/envtest/webhook.go @@ -147,6 +147,8 @@ func (o *WebhookInstallOptions) PrepWithoutInstalling() error { // Install installs specified webhooks to the API server. func (o *WebhookInstallOptions) Install(config *rest.Config) error { + defaultWebhookOptions(o) + if len(o.LocalServingCAData) == 0 { if err := o.PrepWithoutInstalling(); err != nil { return err @@ -168,6 +170,16 @@ func (o *WebhookInstallOptions) Cleanup() error { return nil } +// defaultWebhookOptions sets the default values for Webhooks. +func defaultWebhookOptions(o *WebhookInstallOptions) { + if o.MaxTime == 0 { + o.MaxTime = defaultMaxWait + } + if o.PollInterval == 0 { + o.PollInterval = defaultPollInterval + } +} + // WaitForWebhooks waits for the Webhooks to be available through API server. func WaitForWebhooks(config *rest.Config, mutatingWebhooks []*admissionv1.MutatingWebhookConfiguration,