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 <[email protected]>
(cherry picked from commit 2328a53)
  • Loading branch information
PhanLe1010 committed Aug 26, 2024
1 parent babd973 commit f2733a6
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 datastore.IsDataEngineV2(volume.Spec.DataEngine) {
if volume.Spec.DataLocality != longhorn.DataLocalityDisabled {
Expand Down Expand Up @@ -327,9 +331,6 @@ func mutate(newObj runtime.Object, moreLabels map[string]string) (admission.Patc
// Always mutate the offlineReplicaRebuilding to disabled for non-SPDK volumes
patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/offlineReplicaRebuilding", "value": "%s"}`, longhorn.OfflineReplicaRebuildingDisabled))
}
if volume.Spec.DataLocality == longhorn.DataLocalityStrictLocal {
patchOps = append(patchOps, `{"op": "replace", "path": "/spec/revisionCounterDisabled", "value": true}`)
}

labels := volume.Labels
if labels == nil {
Expand Down

0 comments on commit f2733a6

Please sign in to comment.