@@ -36,7 +36,7 @@ type Handler interface {
3636 DeleteSnapshot (content * crdv1.VolumeSnapshotContent , snapshotterCredentials map [string ]string ) error
3737 GetSnapshotStatus (content * crdv1.VolumeSnapshotContent , snapshotterListCredentials map [string ]string ) (bool , time.Time , int64 , string , error )
3838 CreateGroupSnapshot (content * crdv1alpha1.VolumeGroupSnapshotContent , parameters map [string ]string , snapshotterCredentials map [string ]string ) (string , string , []* csi.Snapshot , time.Time , bool , error )
39- GetGroupSnapshotStatus (content * crdv1alpha1.VolumeGroupSnapshotContent , snapshotterListCredentials map [string ]string ) (bool , time.Time , error )
39+ GetGroupSnapshotStatus (groupSnapshotContent * crdv1alpha1.VolumeGroupSnapshotContent , snapshotIDs [] string , snapshotterListCredentials map [string ]string ) (bool , time.Time , error )
4040 DeleteGroupSnapshot (content * crdv1alpha1.VolumeGroupSnapshotContent , SnapshotID []string , snapshotterCredentials map [string ]string ) error
4141}
4242
@@ -188,23 +188,27 @@ func (handler *csiHandler) DeleteGroupSnapshot(content *crdv1alpha1.VolumeGroupS
188188 return handler .groupSnapshotter .DeleteGroupSnapshot (ctx , groupSnapshotHandle , snapshotIDs , snapshotterCredentials )
189189}
190190
191- func (handler * csiHandler ) GetGroupSnapshotStatus (groupSnapshotContent * crdv1alpha1.VolumeGroupSnapshotContent , snapshotterListCredentials map [string ]string ) (bool , time.Time , error ) {
191+ func (handler * csiHandler ) GetGroupSnapshotStatus (content * crdv1alpha1.VolumeGroupSnapshotContent , snapshotIDs [] string , snapshotterListCredentials map [string ]string ) (bool , time.Time , error ) {
192192 ctx , cancel := context .WithTimeout (context .Background (), handler .timeout )
193193 defer cancel ()
194194
195+ // NOTE: snapshotIDs are required for GetGroupSnapshotStatus
196+ if len (snapshotIDs ) == 0 {
197+ return false , time.Time {}, fmt .Errorf ("cannot list group snapshot %s. No snapshots found in the group snapshot content" , content .Name )
198+ }
195199 var groupSnapshotHandle string
196200 var err error
197- if groupSnapshotContent .Status != nil && groupSnapshotContent .Status .VolumeGroupSnapshotHandle != nil {
198- groupSnapshotHandle = * groupSnapshotContent .Status .VolumeGroupSnapshotHandle
199- } else if groupSnapshotContent .Spec .Source .GroupSnapshotHandles != nil {
200- groupSnapshotHandle = groupSnapshotContent .Spec .Source .GroupSnapshotHandles .VolumeGroupSnapshotHandle
201+ if content .Status != nil && content .Status .VolumeGroupSnapshotHandle != nil {
202+ groupSnapshotHandle = * content .Status .VolumeGroupSnapshotHandle
203+ } else if content .Spec .Source .GroupSnapshotHandles != nil {
204+ groupSnapshotHandle = content .Spec .Source .GroupSnapshotHandles .VolumeGroupSnapshotHandle
201205 } else {
202- return false , time.Time {}, fmt .Errorf ("failed to list group snapshot for group snapshot content %s: groupSnapshotHandle is missing" , groupSnapshotContent .Name )
206+ return false , time.Time {}, fmt .Errorf ("failed to list group snapshot for group snapshot content %s: groupSnapshotHandle is missing" , content .Name )
203207 }
204208
205- csiSnapshotStatus , timestamp , err := handler .groupSnapshotter .GetGroupSnapshotStatus (ctx , groupSnapshotHandle , snapshotterListCredentials )
209+ csiSnapshotStatus , timestamp , err := handler .groupSnapshotter .GetGroupSnapshotStatus (ctx , groupSnapshotHandle , snapshotIDs , snapshotterListCredentials )
206210 if err != nil {
207- return false , time.Time {}, fmt .Errorf ("failed to list group snapshot for group snapshot content %s: %q" , groupSnapshotContent .Name , err )
211+ return false , time.Time {}, fmt .Errorf ("failed to list group snapshot for group snapshot content %s: %q" , content .Name , err )
208212 }
209213
210214 return csiSnapshotStatus , timestamp , nil
0 commit comments