@@ -30,6 +30,7 @@ import (
30
30
"k8s.io/client-go/tools/cache"
31
31
klog "k8s.io/klog/v2"
32
32
33
+ "github.com/container-storage-interface/spec/lib/go/csi"
33
34
crdv1beta2 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta2"
34
35
crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
35
36
"github.com/kubernetes-csi/external-snapshotter/v8/pkg/utils"
@@ -439,15 +440,13 @@ func (ctrl *csiSnapshotSideCarController) createGroupSnapshotWrapper(groupSnapsh
439
440
}
440
441
441
442
// Create individual snapshots and snapshot contents
442
- var snapshotContentLinks []snapshotContentNameVolumeHandlePair
443
- for _ , snapshot := range snapshots {
444
- snapshotContentLinks = append (snapshotContentLinks , snapshotContentNameVolumeHandlePair {
445
- snapshotHandle : snapshot .SnapshotId ,
446
- volumeHandle : snapshot .SourceVolumeId ,
447
- })
448
- }
449
-
450
- newGroupSnapshotContent , err := ctrl .updateGroupSnapshotContentStatus (groupSnapshotContent , groupSnapshotID , readyToUse , metav1 .NewTime (creationTime ), snapshotContentLinks )
443
+ newGroupSnapshotContent , err := ctrl .updateGroupSnapshotContentStatus (
444
+ groupSnapshotContent ,
445
+ groupSnapshotID ,
446
+ readyToUse ,
447
+ metav1 .NewTime (creationTime ),
448
+ snapshots ,
449
+ )
451
450
if err != nil {
452
451
klog .Errorf ("error updating status for volume group snapshot content %s: %v." , groupSnapshotContent .Name , err )
453
452
return groupSnapshotContent , fmt .Errorf ("error updating status for volume group snapshot content %s: %v" , groupSnapshotContent .Name , err )
@@ -583,7 +582,7 @@ func (ctrl *csiSnapshotSideCarController) updateGroupSnapshotContentStatus(
583
582
groupSnapshotHandle string ,
584
583
readyToUse bool ,
585
584
createdAt metav1.Time ,
586
- snapshotContentLinks []snapshotContentNameVolumeHandlePair ,
585
+ snapshotList []* csi. Snapshot ,
587
586
) (* crdv1beta2.VolumeGroupSnapshotContent , error ) {
588
587
klog .V (5 ).Infof ("updateGroupSnapshotContentStatus: updating VolumeGroupSnapshotContent [%s], groupSnapshotHandle %s, readyToUse %v, createdAt %v" , groupSnapshotContent .Name , groupSnapshotHandle , readyToUse , createdAt )
589
588
@@ -600,11 +599,13 @@ func (ctrl *csiSnapshotSideCarController) updateGroupSnapshotContentStatus(
600
599
ReadyToUse : & readyToUse ,
601
600
CreationTime : & createdAt ,
602
601
}
603
- for _ , snapshotContentLink := range snapshotContentLinks {
604
-
602
+ for _ , snapshot := range snapshotList {
605
603
newStatus .VolumeSnapshotInfoList = append (newStatus .VolumeSnapshotInfoList , crdv1beta2.VolumeSnapshotInfo {
606
- VolumeHandle : snapshotContentLink .volumeHandle ,
607
- SnapshotHandle : snapshotContentLink .snapshotHandle ,
604
+ VolumeHandle : snapshot .SourceVolumeId ,
605
+ SnapshotHandle : snapshot .SnapshotId ,
606
+ CreationTime : utils .CsiTimestampToKubernetes (snapshot .CreationTime ),
607
+ ReadyToUse : & snapshot .ReadyToUse ,
608
+ RestoreSize : utils .CsiSizeToKubernetes (snapshot .SizeBytes ),
608
609
})
609
610
}
610
611
@@ -627,10 +628,13 @@ func (ctrl *csiSnapshotSideCarController) updateGroupSnapshotContentStatus(
627
628
updated = true
628
629
}
629
630
if len (newStatus .VolumeSnapshotInfoList ) == 0 {
630
- for _ , snapshotContentLink := range snapshotContentLinks {
631
+ for _ , snapshot := range snapshotList {
631
632
newStatus .VolumeSnapshotInfoList = append (newStatus .VolumeSnapshotInfoList , crdv1beta2.VolumeSnapshotInfo {
632
- VolumeHandle : snapshotContentLink .volumeHandle ,
633
- SnapshotHandle : snapshotContentLink .snapshotHandle ,
633
+ VolumeHandle : snapshot .SourceVolumeId ,
634
+ SnapshotHandle : snapshot .SnapshotId ,
635
+ CreationTime : utils .CsiTimestampToKubernetes (snapshot .CreationTime ),
636
+ ReadyToUse : & snapshot .ReadyToUse ,
637
+ RestoreSize : utils .CsiSizeToKubernetes (snapshot .SizeBytes ),
634
638
})
635
639
}
636
640
updated = true
@@ -793,7 +797,7 @@ func (ctrl *csiSnapshotSideCarController) checkandUpdateGroupSnapshotContentStat
793
797
}
794
798
795
799
// TODO: Get a reference to snapshot contents for this volume group snapshot
796
- updatedContent , err := ctrl .updateGroupSnapshotContentStatus (groupSnapshotContent , groupSnapshotID , readyToUse , metav1 .NewTime (creationTime ), []snapshotContentNameVolumeHandlePair {})
800
+ updatedContent , err := ctrl .updateGroupSnapshotContentStatus (groupSnapshotContent , groupSnapshotID , readyToUse , metav1 .NewTime (creationTime ), []* csi. Snapshot {})
797
801
if err != nil {
798
802
return groupSnapshotContent , err
799
803
}
0 commit comments