Skip to content

Commit 456b8af

Browse files
committed
Avoid conflicts in updateSnapshotContentStatus
This patch replace the usage of `UpdateStatus` with a patch against the `status` subresource in the `updateSnapshotContentStatus`. The reason behind this change is to avoid conflicts that could potentially arise, as they pose a risk within the context of the calling function `createGroupSnapshotWrapper`. If `createGroupSnapshotWrapper` is called multiple times for the same GroupSnapshot, this will lead to multiple stale `VolumeSnapshot` and `VolumeSnapshotContent` being created. Related to: #1050
1 parent 3a35a5e commit 456b8af

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pkg/sidecar-controller/snapshot_controller.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,16 @@ func (ctrl *csiSnapshotSideCarController) updateSnapshotContentStatus(
484484

485485
if updated {
486486
contentClone := contentObj.DeepCopy()
487-
contentClone.Status = newStatus
488-
newContent, err := ctrl.clientset.SnapshotV1().VolumeSnapshotContents().UpdateStatus(context.TODO(), contentClone, metav1.UpdateOptions{})
487+
488+
patches := []utils.PatchOp{
489+
{
490+
Op: "replace",
491+
Path: "/status",
492+
Value: newStatus,
493+
},
494+
}
495+
496+
newContent, err := utils.PatchVolumeSnapshotContent(contentClone, patches, ctrl.clientset, "status")
489497
if err != nil {
490498
return contentObj, newControllerUpdateError(content.Name, err.Error())
491499
}

0 commit comments

Comments
 (0)