From 5da0cb807a4f0a626149af408b05dd6ea943c0f1 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 28 Mar 2023 16:34:54 +0200 Subject: [PATCH] NetworkFence: correct check in validating webhook When a NetworkFence CR is validated, an incorrect comparison is done. `DeepEqual()` returns `true` when the there are no changes, this is valid and not an error. Adding `!` to inverse the check corrects the comparison and only reports an error when the parameters are modified. See-also: https://bugzilla.redhat.com/2182375 Signed-off-by: Niels de Vos --- apis/csiaddons/v1alpha1/networkfence_webhook.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/csiaddons/v1alpha1/networkfence_webhook.go b/apis/csiaddons/v1alpha1/networkfence_webhook.go index 0f4d69758..eb9b57ec6 100644 --- a/apis/csiaddons/v1alpha1/networkfence_webhook.go +++ b/apis/csiaddons/v1alpha1/networkfence_webhook.go @@ -61,7 +61,7 @@ func (n *NetworkFence) ValidateUpdate(old runtime.Object) error { allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("driver"), n.Spec.Driver, "driver cannot be changed")) } - if reflect.DeepEqual(n.Spec.Parameters, oldNetworkFence.Spec.Parameters) { + if !reflect.DeepEqual(n.Spec.Parameters, oldNetworkFence.Spec.Parameters) { allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("parameters"), n.Spec.Parameters, "parameters cannot be changed")) }