@@ -743,7 +743,7 @@ func (ctrl *csiSnapshotCommonController) createGroupSnapshotContent(groupSnapsho
743743 TODO: Add PVC finalizer
744744 */
745745
746- groupSnapshotClass , volumes , contentName , err := ctrl .getCreateGroupSnapshotInput (groupSnapshot )
746+ groupSnapshotClass , volumes , contentName , snapshotterSecretRef , err := ctrl .getCreateGroupSnapshotInput (groupSnapshot )
747747 if err != nil {
748748 return nil , fmt .Errorf ("failed to get input parameters to create group snapshot %s: %q" , groupSnapshot .Name , err )
749749 }
@@ -773,8 +773,15 @@ func (ctrl *csiSnapshotCommonController) createGroupSnapshotContent(groupSnapsho
773773 }
774774
775775 /*
776- TODO: Add secret reference details
776+ Add secret reference details
777777 */
778+ if snapshotterSecretRef != nil {
779+ klog .V (5 ).Infof ("createGroupSnapshotContent: set annotation [%s] on volume group snapshot content [%s]." , utils .AnnDeletionSecretRefName , groupSnapshotContent .Name )
780+ metav1 .SetMetaDataAnnotation (& groupSnapshotContent .ObjectMeta , utils .AnnDeletionSecretRefName , snapshotterSecretRef .Name )
781+
782+ klog .V (5 ).Infof ("creategroupSnapshotContent: set annotation [%s] on volume group snapshot content [%s]." , utils .AnnDeletionSecretRefNamespace , groupSnapshotContent .Name )
783+ metav1 .SetMetaDataAnnotation (& groupSnapshotContent .ObjectMeta , utils .AnnDeletionSecretRefNamespace , snapshotterSecretRef .Namespace )
784+ }
778785
779786 var updateGroupSnapshotContent * crdv1alpha1.VolumeGroupSnapshotContent
780787 klog .V (5 ).Infof ("volume group snapshot content %#v" , groupSnapshotContent )
@@ -810,7 +817,7 @@ func (ctrl *csiSnapshotCommonController) createGroupSnapshotContent(groupSnapsho
810817 return updateGroupSnapshotContent , nil
811818}
812819
813- func (ctrl * csiSnapshotCommonController ) getCreateGroupSnapshotInput (groupSnapshot * crdv1alpha1.VolumeGroupSnapshot ) (* crdv1alpha1.VolumeGroupSnapshotClass , []* v1.PersistentVolume , string , error ) {
820+ func (ctrl * csiSnapshotCommonController ) getCreateGroupSnapshotInput (groupSnapshot * crdv1alpha1.VolumeGroupSnapshot ) (* crdv1alpha1.VolumeGroupSnapshotClass , []* v1.PersistentVolume , string , * v1. SecretReference , error ) {
814821 className := groupSnapshot .Spec .VolumeGroupSnapshotClassName
815822 klog .V (5 ).Infof ("getCreateGroupSnapshotInput [%s]" , groupSnapshot .Name )
816823 var groupSnapshotClass * crdv1alpha1.VolumeGroupSnapshotClass
@@ -819,23 +826,29 @@ func (ctrl *csiSnapshotCommonController) getCreateGroupSnapshotInput(groupSnapsh
819826 groupSnapshotClass , err = ctrl .getGroupSnapshotClass (* className )
820827 if err != nil {
821828 klog .Errorf ("getCreateGroupSnapshotInput failed to getClassFromVolumeGroupSnapshot %s" , err )
822- return nil , nil , "" , err
829+ return nil , nil , "" , nil , err
823830 }
824831 } else {
825832 klog .Errorf ("failed to getCreateGroupSnapshotInput %s without a group snapshot class" , groupSnapshot .Name )
826- return nil , nil , "" , fmt .Errorf ("failed to take group snapshot %s without a group snapshot class" , groupSnapshot .Name )
833+ return nil , nil , "" , nil , fmt .Errorf ("failed to take group snapshot %s without a group snapshot class" , groupSnapshot .Name )
827834 }
828835
829836 volumes , err := ctrl .getVolumesFromVolumeGroupSnapshot (groupSnapshot )
830837 if err != nil {
831838 klog .Errorf ("getCreateGroupSnapshotInput failed to get PersistentVolume objects [%s]: Error: [%#v]" , groupSnapshot .Name , err )
832- return nil , nil , "" , err
839+ return nil , nil , "" , nil , err
833840 }
834841
835842 // Create VolumeGroupSnapshotContent name
836843 contentName := utils .GetDynamicSnapshotContentNameForGroupSnapshot (groupSnapshot )
837844
838- return groupSnapshotClass , volumes , contentName , nil
845+ // Get the secret reference
846+ snapshotterSecretRef , err := utils .GetGroupSnapshotSecretReference (utils .SnapshotterSecretParams , groupSnapshotClass .Parameters , contentName , groupSnapshot )
847+ if err != nil {
848+ return nil , nil , "" , nil , err
849+ }
850+
851+ return groupSnapshotClass , volumes , contentName , snapshotterSecretRef , nil
839852}
840853
841854// syncGroupSnapshotContent deals with one key off the queue
0 commit comments