@@ -743,7 +743,7 @@ func (ctrl *csiSnapshotCommonController) createGroupSnapshotContent(groupSnapsho
743
743
TODO: Add PVC finalizer
744
744
*/
745
745
746
- groupSnapshotClass , volumes , contentName , err := ctrl .getCreateGroupSnapshotInput (groupSnapshot )
746
+ groupSnapshotClass , volumes , contentName , snapshotterSecretRef , err := ctrl .getCreateGroupSnapshotInput (groupSnapshot )
747
747
if err != nil {
748
748
return nil , fmt .Errorf ("failed to get input parameters to create group snapshot %s: %q" , groupSnapshot .Name , err )
749
749
}
@@ -773,8 +773,15 @@ func (ctrl *csiSnapshotCommonController) createGroupSnapshotContent(groupSnapsho
773
773
}
774
774
775
775
/*
776
- TODO: Add secret reference details
776
+ Add secret reference details
777
777
*/
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
+ }
778
785
779
786
var updateGroupSnapshotContent * crdv1alpha1.VolumeGroupSnapshotContent
780
787
klog .V (5 ).Infof ("volume group snapshot content %#v" , groupSnapshotContent )
@@ -810,7 +817,7 @@ func (ctrl *csiSnapshotCommonController) createGroupSnapshotContent(groupSnapsho
810
817
return updateGroupSnapshotContent , nil
811
818
}
812
819
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 ) {
814
821
className := groupSnapshot .Spec .VolumeGroupSnapshotClassName
815
822
klog .V (5 ).Infof ("getCreateGroupSnapshotInput [%s]" , groupSnapshot .Name )
816
823
var groupSnapshotClass * crdv1alpha1.VolumeGroupSnapshotClass
@@ -819,23 +826,29 @@ func (ctrl *csiSnapshotCommonController) getCreateGroupSnapshotInput(groupSnapsh
819
826
groupSnapshotClass , err = ctrl .getGroupSnapshotClass (* className )
820
827
if err != nil {
821
828
klog .Errorf ("getCreateGroupSnapshotInput failed to getClassFromVolumeGroupSnapshot %s" , err )
822
- return nil , nil , "" , err
829
+ return nil , nil , "" , nil , err
823
830
}
824
831
} else {
825
832
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 )
827
834
}
828
835
829
836
volumes , err := ctrl .getVolumesFromVolumeGroupSnapshot (groupSnapshot )
830
837
if err != nil {
831
838
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
833
840
}
834
841
835
842
// Create VolumeGroupSnapshotContent name
836
843
contentName := utils .GetDynamicSnapshotContentNameForGroupSnapshot (groupSnapshot )
837
844
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
839
852
}
840
853
841
854
// syncGroupSnapshotContent deals with one key off the queue
0 commit comments