From 8d72634a69f924cae4d6dcb9ee3f08c803c2a074 Mon Sep 17 00:00:00 2001 From: Xiangjing Li <55890329+xiangjingli@users.noreply.github.com> Date: Tue, 15 Mar 2022 22:43:15 -0400 Subject: [PATCH] Cannot install ACM successfully due to failed call webhook sometimes (#36) * Cannot install ACM successfully due to failed call webhook sometimes Signed-off-by: Xiangjing Li --- pkg/webhook/wireupwebhook.go | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/pkg/webhook/wireupwebhook.go b/pkg/webhook/wireupwebhook.go index 31b39d1..54f6c95 100644 --- a/pkg/webhook/wireupwebhook.go +++ b/pkg/webhook/wireupwebhook.go @@ -313,6 +313,12 @@ func (w *WireUp) createOrUpdateValiationWebhook(isExternalAPIServer bool, inClie validator.Webhooks[0].ClientConfig.Service.Name = w.WebHookeSvcKey.Name validator.Webhooks[0].ClientConfig.CABundle = ca + ignore := admissionv1.Ignore + timeoutSeconds := int32(30) + + validator.Webhooks[0].FailurePolicy = &ignore + validator.Webhooks[0].TimeoutSeconds = &timeoutSeconds + setWebhookOwnerReferences(w.mgr.GetClient(), w.Logger, validator) if err := w.mgr.GetClient().Update(context.TODO(), validator); err != nil { @@ -440,8 +446,9 @@ func newWebhookEndpointTemplate(svcKey types.NamespacedName, webHookServicePort func newValidatingWebhookCfg(svcKey types.NamespacedName, validatorName, path string, ca []byte, gvk schema.GroupVersionKind, ops []admissionv1.OperationType) *admissionv1.ValidatingWebhookConfiguration { - fail := admissionv1.Fail + ignore := admissionv1.Ignore side := admissionv1.SideEffectClassNone + timeoutSeconds := int32(30) return &admissionv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ @@ -452,7 +459,7 @@ func newValidatingWebhookCfg(svcKey types.NamespacedName, validatorName, path st Name: validatorName, AdmissionReviewVersions: []string{"v1beta1"}, SideEffects: &side, - FailurePolicy: &fail, + FailurePolicy: &ignore, ClientConfig: admissionv1.WebhookClientConfig{ Service: &admissionv1.ServiceReference{ Name: svcKey.Name, @@ -461,15 +468,18 @@ func newValidatingWebhookCfg(svcKey types.NamespacedName, validatorName, path st }, CABundle: ca, }, - Rules: []admissionv1.RuleWithOperations{{ - Rule: admissionv1.Rule{ - APIGroups: []string{gvk.Group}, - APIVersions: []string{gvk.Version}, - Resources: []string{gvk.Kind}, + Rules: []admissionv1.RuleWithOperations{ + { + Rule: admissionv1.Rule{ + APIGroups: []string{gvk.Group}, + APIVersions: []string{gvk.Version}, + Resources: []string{gvk.Kind}, + }, + Operations: ops, }, - Operations: ops, }, - }}, + TimeoutSeconds: &timeoutSeconds, + }, }, } }