Skip to content

Commit

Permalink
envtest: set default webhook options for polling
Browse files Browse the repository at this point in the history
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 <mikko.ylinen@intel.com>
  • Loading branch information
mythi committed Apr 26, 2023
1 parent 0f5aba9 commit 007dc76
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/envtest/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 007dc76

Please sign in to comment.