From d7a91d0108102d00d7f7a0e7f7d86110ce9c046b Mon Sep 17 00:00:00 2001 From: Phan Le Date: Fri, 23 Aug 2024 14:37:26 -0700 Subject: [PATCH] fix(webhook): do not change the revisionCounterDisabled It is an immutable field after creation longhorn-927 Signed-off-by: Phan Le (cherry picked from commit 2328a53044ba42446d15e60a7d2bd473de9d73ed) --- webhook/resources/volume/mutator.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webhook/resources/volume/mutator.go b/webhook/resources/volume/mutator.go index e1b9654079..eb2258de86 100644 --- a/webhook/resources/volume/mutator.go +++ b/webhook/resources/volume/mutator.go @@ -190,6 +190,10 @@ func (v *volumeMutator) Create(request *admission.Request, newObj runtime.Object patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/snapshotMaxCount", "value": %v}`, snapshotMaxCount)) } + if volume.Spec.DataLocality == longhorn.DataLocalityStrictLocal { + patchOps = append(patchOps, `{"op": "replace", "path": "/spec/revisionCounterDisabled", "value": true}`) + } + // TODO: Remove the mutations below after they are implemented for SPDK volumes if types.IsDataEngineV2(volume.Spec.DataEngine) { if volume.Spec.DataLocality != longhorn.DataLocalityDisabled { @@ -325,9 +329,6 @@ func mutate(newObj runtime.Object, moreLabels map[string]string) (admission.Patc if string(volume.Spec.DataEngine) == "" { patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/dataEngine", "value": "%s"}`, longhorn.DataEngineTypeV1)) } - if volume.Spec.DataLocality == longhorn.DataLocalityStrictLocal { - patchOps = append(patchOps, `{"op": "replace", "path": "/spec/revisionCounterDisabled", "value": true}`) - } if string(volume.Spec.FreezeFilesystemForSnapshot) == "" { patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/freezeFilesystemForSnapshot", "value": "%s"}`, longhorn.FreezeFilesystemForSnapshotDefault)) }