Skip to content

Commit 34c5bff

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. Partially closes: kubernetes-csi#1050
1 parent 3a35a5e commit 34c5bff

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/sidecar-controller/snapshot_controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,16 @@ func (ctrl *csiSnapshotSideCarController) updateSnapshotContentStatus(
485485
if updated {
486486
contentClone := contentObj.DeepCopy()
487487
contentClone.Status = newStatus
488-
newContent, err := ctrl.clientset.SnapshotV1().VolumeSnapshotContents().UpdateStatus(context.TODO(), contentClone, metav1.UpdateOptions{})
488+
489+
patches := []utils.PatchOp{
490+
{
491+
Op: "replace",
492+
Path: "/status",
493+
Value: newStatus,
494+
},
495+
}
496+
497+
newContent, err := utils.PatchVolumeSnapshotContent(contentClone, patches, ctrl.clientset, "status")
489498
if err != nil {
490499
return contentObj, newControllerUpdateError(content.Name, err.Error())
491500
}

0 commit comments

Comments
 (0)