Skip to content

Commit

Permalink
fix(webhook): do not change the revisionCounterDisabled
Browse files Browse the repository at this point in the history
It is an immutable field after creation

longhorn-927

Signed-off-by: Phan Le <phan.le@suse.com>
(cherry picked from commit 2328a53)
  • Loading branch information
PhanLe1010 authored and mergify[bot] committed Aug 24, 2024
1 parent 7278746 commit 4340626
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions webhook/resources/volume/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
}
Expand Down

0 comments on commit 4340626

Please sign in to comment.