From 866f5925e6e62d9b4a3284b686e50e398b1c2d00 Mon Sep 17 00:00:00 2001 From: prateekpandey14 Date: Tue, 8 Dec 2020 15:09:56 +0530 Subject: [PATCH] fix(webhook): update webhook config sideEffects to None To support dry run command, validatingwebhookconfiguration SideEffects needs to be set as None. Signed-off-by: prateekpandey14 --- pkg/webhook/configuration.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/webhook/configuration.go b/pkg/webhook/configuration.go index a22e19703b..43ac8f796a 100644 --- a/pkg/webhook/configuration.go +++ b/pkg/webhook/configuration.go @@ -71,6 +71,8 @@ var ( Ignore = v1beta1.Ignore // Fail means that an error calling the webhook causes the admission to fail. Fail = v1beta1.Fail + // SideEffectClassNone means that calling the webhook will have no side effects. + SideEffectClassNone = v1beta1.SideEffectClassNone // WebhookFailurePolicye represents failure policy env name to make it configurable // via ENV WebhookFailurePolicy = "ADMISSION_WEBHOOK_FAILURE_POLICY" @@ -82,6 +84,7 @@ var ( addCVCWithUpdateRule, addSPCWithDeleteRule, addNSWithDeleteRule, + addSideEffects, } cvcRuleWithOperations = v1beta1.RuleWithOperations{ Operations: []v1beta1.OperationType{ @@ -237,6 +240,7 @@ func createValidatingWebhookConfig( }, TimeoutSeconds: &five, FailurePolicy: failurePolicy(), + SideEffects: &SideEffectClassNone, } validator := &v1beta1.ValidatingWebhookConfiguration{ @@ -525,6 +529,12 @@ func addNSWithDeleteRule(config *v1beta1.ValidatingWebhookConfiguration) { } } +func addSideEffects(config *v1beta1.ValidatingWebhookConfiguration) { + if util.IsCurrentLessThanNewVersion(config.Labels[string(apis.OpenEBSVersionKey)], "2.4.0") { + config.Webhooks[0].SideEffects = &SideEffectClassNone + } +} + func getOldService(openebsNamespace string) (*corev1.ServiceList, error) { v100SVCName := "admission-server-svc" // fetch service 1.1.0 onwards based on label