@@ -609,7 +609,7 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
609
609
},
610
610
Spec : crdv1.VolumeSnapshotSpec {
611
611
Source : crdv1.VolumeSnapshotSource {
612
- VolumeSnapshotContentName : & volumeSnapshotContentName ,
612
+ PersistentVolumeClaimName : & pv . Spec . ClaimRef . Name ,
613
613
},
614
614
},
615
615
// The status will be set by VolumeSnapshot reconciler
@@ -621,7 +621,7 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
621
621
"createSnapshotsForGroupSnapshotContent: creating volumesnapshotcontent %w" , err )
622
622
}
623
623
624
- _ , err = ctrl .clientset .SnapshotV1 ().VolumeSnapshots (volumeSnapshotNamespace ).Create (ctx , volumeSnapshot , metav1.CreateOptions {})
624
+ createdVolumeSnapshot , err : = ctrl .clientset .SnapshotV1 ().VolumeSnapshots (volumeSnapshotNamespace ).Create (ctx , volumeSnapshot , metav1.CreateOptions {})
625
625
if err != nil && ! apierrs .IsAlreadyExists (err ) {
626
626
return groupSnapshotContent , fmt .Errorf (
627
627
"createSnapshotsForGroupSnapshotContent: creating volumesnapshot %w" , err )
@@ -637,6 +637,40 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
637
637
Name : pv .Name ,
638
638
}
639
639
}
640
+
641
+ // bind the volume snapshot content to the volume snapshot
642
+ // like a dynamically provisioned snapshot would do
643
+ volumeSnapshotContent .Spec .VolumeSnapshotRef .UID = createdVolumeSnapshot .UID
644
+ _ , err = utils .PatchVolumeSnapshotContent (volumeSnapshotContent , []utils.PatchOp {
645
+ {
646
+ Op : "replace" ,
647
+ Path : "/spec/volumeSnapshotRef/uid" ,
648
+ Value : volumeSnapshotContent .Spec .VolumeSnapshotRef .UID ,
649
+ },
650
+ }, ctrl .clientset )
651
+ if err != nil {
652
+ return groupSnapshotContent , fmt .Errorf (
653
+ "createSnapshotsForGroupSnapshotContent: binding volumesnapshotcontent to volumesnapshot %w" , err )
654
+ }
655
+
656
+ // bind the volume snapshot to the volume snapshot content
657
+ // like a dynamically provisioned snapshot would do
658
+ _ , err = utils .PatchVolumeSnapshot (createdVolumeSnapshot , []utils.PatchOp {
659
+ {
660
+ Op : "replace" ,
661
+ Path : "/status" ,
662
+ Value : & crdv1.VolumeSnapshotStatus {},
663
+ },
664
+ {
665
+ Op : "replace" ,
666
+ Path : "/status/boundVolumeSnapshotContentName" ,
667
+ Value : volumeSnapshotContentName ,
668
+ },
669
+ }, ctrl .clientset , "status" )
670
+ if err != nil {
671
+ return groupSnapshotContent , fmt .Errorf (
672
+ "createSnapshotsForGroupSnapshotContent: binding volumesnapshot to volumesnapshotcontent %w" , err )
673
+ }
640
674
}
641
675
642
676
// Phase 2: set the backlinks
0 commit comments