@@ -533,11 +533,7 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
533533 "createSnapshotsForGroupSnapshotContent[%s]: creating volumesnapshots and volumesnapshotcontent for group snapshot content" ,
534534 groupSnapshotContent .Name )
535535
536- groupSnapshotContent .Status .PVVolumeSnapshotContentList = make (
537- []crdv1alpha1.PVVolumeSnapshotContentPair ,
538- len (groupSnapshotContent .Status .VolumeSnapshotHandlePairList ),
539- )
540- for i , snapshot := range groupSnapshotContent .Status .VolumeSnapshotHandlePairList {
536+ for _ , snapshot := range groupSnapshotContent .Status .VolumeSnapshotHandlePairList {
541537 snapshotHandle := snapshot .SnapshotHandle
542538 volumeHandle := snapshot .VolumeHandle
543539
@@ -619,17 +615,6 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
619615 "createSnapshotsForGroupSnapshotContent: creating volumesnapshot %w" , err )
620616 }
621617
622- groupSnapshotContent .Status .PVVolumeSnapshotContentList [i ] = crdv1alpha1.PVVolumeSnapshotContentPair {
623- VolumeSnapshotContentRef : v1.LocalObjectReference {
624- Name : volumeSnapshotContentName ,
625- },
626- }
627- if pv != nil {
628- groupSnapshotContent .Status .PVVolumeSnapshotContentList [i ].PersistentVolumeRef = v1.LocalObjectReference {
629- Name : pv .Name ,
630- }
631- }
632-
633618 // bind the volume snapshot content to the volume snapshot
634619 // like a dynamically provisioned snapshot would do
635620 volumeSnapshotContent .Spec .VolumeSnapshotRef .UID = createdVolumeSnapshot .UID
@@ -665,24 +650,7 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
665650 }
666651 }
667652
668- // Phase 2: set the backlinks
669- var patches []utils.PatchOp
670- patches = append (patches , utils.PatchOp {
671- Op : "replace" ,
672- Path : "/status/pvVolumeSnapshotContentList" ,
673- Value : groupSnapshotContent .Status .PVVolumeSnapshotContentList ,
674- })
675-
676- newGroupSnapshotObj , err := utils .PatchVolumeGroupSnapshotContent (
677- groupSnapshotContent ,
678- patches ,
679- ctrl .clientset ,
680- "status" )
681- if err != nil {
682- return nil , newControllerUpdateError (utils .GroupSnapshotKey (groupSnapshot ), err .Error ())
683- }
684-
685- return newGroupSnapshotObj , nil
653+ return groupSnapshotContent , nil
686654}
687655
688656// findPersistentVolumeByCSIDriverHandle looks at an existing PersistentVolume
@@ -836,50 +804,6 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshotStatus(groupSnapshot
836804 volumeSnapshotErr = groupSnapshotContent .Status .Error .DeepCopy ()
837805 }
838806
839- var pvcVolumeSnapshotRefList []crdv1alpha1.PVCVolumeSnapshotPair
840- if groupSnapshotContent .Status != nil && len (groupSnapshotContent .Status .PVVolumeSnapshotContentList ) != 0 {
841- for _ , contentRef := range groupSnapshotContent .Status .PVVolumeSnapshotContentList {
842- var pvcReference v1.LocalObjectReference
843- pv , err := ctrl .client .CoreV1 ().PersistentVolumes ().Get (context .TODO (), contentRef .PersistentVolumeRef .Name , metav1.GetOptions {})
844- if err != nil {
845- if apierrs .IsNotFound (err ) {
846- klog .Errorf (
847- "updateGroupSnapshotStatus[%s]: PV [%s] not found" ,
848- utils .GroupSnapshotKey (groupSnapshot ),
849- contentRef .PersistentVolumeRef .Name ,
850- )
851- } else {
852- klog .Errorf (
853- "updateGroupSnapshotStatus[%s]: unable to get PV [%s] from the API server: %q" ,
854- utils .GroupSnapshotKey (groupSnapshot ),
855- contentRef .PersistentVolumeRef .Name ,
856- err .Error (),
857- )
858- }
859- } else {
860- if pv .Spec .ClaimRef != nil {
861- pvcReference .Name = pv .Spec .ClaimRef .Name
862- } else {
863- klog .Errorf (
864- "updateGroupSnapshotStatus[%s]: PV [%s] is not bound" ,
865- utils .GroupSnapshotKey (groupSnapshot ),
866- contentRef .PersistentVolumeRef .Name )
867- }
868- }
869-
870- volumeSnapshotContent , err := ctrl .contentLister .Get (contentRef .VolumeSnapshotContentRef .Name )
871- if err != nil {
872- return nil , fmt .Errorf ("failed to get snapshot content %s from snapshot content store: %v" , contentRef .VolumeSnapshotContentRef .Name , err )
873- }
874- pvcVolumeSnapshotRefList = append (pvcVolumeSnapshotRefList , crdv1alpha1.PVCVolumeSnapshotPair {
875- VolumeSnapshotRef : v1.LocalObjectReference {
876- Name : volumeSnapshotContent .Spec .VolumeSnapshotRef .Name ,
877- },
878- PersistentVolumeClaimRef : pvcReference ,
879- })
880- }
881- }
882-
883807 klog .V (5 ).Infof ("updateGroupSnapshotStatus: updating VolumeGroupSnapshot [%+v] based on VolumeGroupSnapshotContentStatus [%+v]" , groupSnapshot , groupSnapshotContent .Status )
884808
885809 groupSnapshotObj , err := ctrl .clientset .GroupsnapshotV1alpha1 ().VolumeGroupSnapshots (groupSnapshot .Namespace ).Get (context .TODO (), groupSnapshot .Name , metav1.GetOptions {})
@@ -900,9 +824,6 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshotStatus(groupSnapshot
900824 if volumeSnapshotErr != nil {
901825 newStatus .Error = volumeSnapshotErr
902826 }
903- if len (pvcVolumeSnapshotRefList ) == 0 {
904- newStatus .PVCVolumeSnapshotRefList = pvcVolumeSnapshotRefList
905- }
906827
907828 updated = true
908829 } else {
@@ -926,10 +847,6 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshotStatus(groupSnapshot
926847 newStatus .Error = volumeSnapshotErr
927848 updated = true
928849 }
929- if len (newStatus .PVCVolumeSnapshotRefList ) == 0 {
930- newStatus .PVCVolumeSnapshotRefList = pvcVolumeSnapshotRefList
931- updated = true
932- }
933850 }
934851
935852 if updated {
0 commit comments