@@ -618,16 +618,27 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
618618 volumeSnapshot .Spec .Source .PersistentVolumeClaimName = & emptyString
619619 }
620620
621- createdVolumeSnapshotContent , err : = ctrl .clientset .SnapshotV1 ().VolumeSnapshotContents ().Create (ctx , volumeSnapshotContent , metav1.CreateOptions {})
621+ _ , err = ctrl .clientset .SnapshotV1 ().VolumeSnapshotContents ().Create (ctx , volumeSnapshotContent , metav1.CreateOptions {})
622622 if err != nil && ! apierrs .IsAlreadyExists (err ) {
623623 return groupSnapshotContent , fmt .Errorf (
624624 "createSnapshotsForGroupSnapshotContent: creating volumesnapshotcontent %w" , err )
625625 }
626626
627627 createdVolumeSnapshot , err := ctrl .clientset .SnapshotV1 ().VolumeSnapshots (volumeSnapshotNamespace ).Create (ctx , volumeSnapshot , metav1.CreateOptions {})
628- if err != nil && ! apierrs .IsAlreadyExists (err ) {
628+ if apierrs .IsAlreadyExists (err ) {
629+ createdVolumeSnapshot , err = ctrl .clientset .SnapshotV1 ().
630+ VolumeSnapshots (volumeSnapshotNamespace ).
631+ Get (ctx , volumeSnapshot .Name , metav1.GetOptions {})
632+ }
633+ if err != nil {
629634 return groupSnapshotContent , fmt .Errorf (
630- "createSnapshotsForGroupSnapshotContent: creating volumesnapshot %w" , err )
635+ "createSnapshotsForGroupSnapshotContent: error creating or fetching volumesnapshot %w" , err )
636+ }
637+
638+ // FIX for cases where the UID might be empty
639+ if createdVolumeSnapshot .GetUID () == "" {
640+ return groupSnapshotContent , fmt .Errorf (
641+ "createSnapshotsForGroupSnapshotContent: created snapshot %s has an empty UID" , createdVolumeSnapshot .Name )
631642 }
632643
633644 // bind the volume snapshot content to the volume snapshot
@@ -667,7 +678,7 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
667678 // set the snapshot handle and the group snapshot handle
668679 // inside the volume snapshot content to allow
669680 // the CSI Snapshotter sidecar to reconcile its status
670- _ , err = utils .PatchVolumeSnapshotContent (createdVolumeSnapshotContent , []utils.PatchOp {
681+ _ , err = utils .PatchVolumeSnapshotContent (volumeSnapshotContent , []utils.PatchOp {
671682 {
672683 Op : "replace" ,
673684 Path : "/status" ,
0 commit comments