Skip to content

Commit

Permalink
Avoid conflicts in updateSnapshotContentStatus
Browse files Browse the repository at this point in the history
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
  • Loading branch information
leonardoce committed Apr 15, 2024
1 parent 3a35a5e commit 34c5bff
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/sidecar-controller/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,16 @@ func (ctrl *csiSnapshotSideCarController) updateSnapshotContentStatus(
if updated {
contentClone := contentObj.DeepCopy()
contentClone.Status = newStatus
newContent, err := ctrl.clientset.SnapshotV1().VolumeSnapshotContents().UpdateStatus(context.TODO(), contentClone, metav1.UpdateOptions{})

patches := []utils.PatchOp{
{
Op: "replace",
Path: "/status",
Value: newStatus,
},
}

newContent, err := utils.PatchVolumeSnapshotContent(contentClone, patches, ctrl.clientset, "status")
if err != nil {
return contentObj, newControllerUpdateError(content.Name, err.Error())
}
Expand Down

0 comments on commit 34c5bff

Please sign in to comment.