Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions pkg/common-controller/groupsnapshot_controller_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,16 +618,27 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
volumeSnapshot.Spec.Source.PersistentVolumeClaimName = &emptyString
}

createdVolumeSnapshotContent, err := ctrl.clientset.SnapshotV1().VolumeSnapshotContents().Create(ctx, volumeSnapshotContent, metav1.CreateOptions{})
_, err = ctrl.clientset.SnapshotV1().VolumeSnapshotContents().Create(ctx, volumeSnapshotContent, metav1.CreateOptions{})
if err != nil && !apierrs.IsAlreadyExists(err) {
return groupSnapshotContent, fmt.Errorf(
"createSnapshotsForGroupSnapshotContent: creating volumesnapshotcontent %w", err)
}

createdVolumeSnapshot, err := ctrl.clientset.SnapshotV1().VolumeSnapshots(volumeSnapshotNamespace).Create(ctx, volumeSnapshot, metav1.CreateOptions{})
if err != nil && !apierrs.IsAlreadyExists(err) {
if apierrs.IsAlreadyExists(err) {
createdVolumeSnapshot, err = ctrl.clientset.SnapshotV1().
VolumeSnapshots(volumeSnapshotNamespace).
Get(ctx, volumeSnapshot.Name, metav1.GetOptions{})
}
if err != nil {
return groupSnapshotContent, fmt.Errorf(
"createSnapshotsForGroupSnapshotContent: creating volumesnapshot %w", err)
"createSnapshotsForGroupSnapshotContent: error creating or fetching volumesnapshot %w", err)
}

// FIX for cases where the UID might be empty
if createdVolumeSnapshot.GetUID() == "" {
return groupSnapshotContent, fmt.Errorf(
"createSnapshotsForGroupSnapshotContent: created snapshot %s has an empty UID", createdVolumeSnapshot.Name)
}

// bind the volume snapshot content to the volume snapshot
Expand Down Expand Up @@ -667,7 +678,7 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
// set the snapshot handle and the group snapshot handle
// inside the volume snapshot content to allow
// the CSI Snapshotter sidecar to reconcile its status
_, err = utils.PatchVolumeSnapshotContent(createdVolumeSnapshotContent, []utils.PatchOp{
_, err = utils.PatchVolumeSnapshotContent(volumeSnapshotContent, []utils.PatchOp{
{
Op: "replace",
Path: "/status",
Expand Down