Add checks for csisnapshot for vol_info population

fixes #7874

Signed-off-by: Daniel Jiang <daniel.jiang@broadcom.com>
pull/7875/head
Daniel Jiang 2024-06-12 18:57:29 +08:00
parent 21366795d1
commit f61c8b9042
1 changed files with 10 additions and 2 deletions

View File

@ -769,6 +769,14 @@ func (t *RestoreVolumeInfoTracker) Result() []*RestoreVolumeInfo {
continue
}
pvcNS, pvcName := n[0], n[1]
var restoreSize int64 = 0
if csiSnapshot.Status != nil && csiSnapshot.Status.RestoreSize != nil {
restoreSize = csiSnapshot.Status.RestoreSize.Value()
}
vscName := ""
if csiSnapshot.Spec.Source.VolumeSnapshotContentName != nil {
vscName = *csiSnapshot.Spec.Source.VolumeSnapshotContentName
}
volumeInfo := &RestoreVolumeInfo{
PVCNamespace: pvcNS,
PVCName: pvcName,
@ -776,9 +784,9 @@ func (t *RestoreVolumeInfoTracker) Result() []*RestoreVolumeInfo {
RestoreMethod: CSISnapshot,
CSISnapshotInfo: &CSISnapshotInfo{
SnapshotHandle: csiSnapshot.Annotations[VolumeSnapshotHandleAnnotation],
Size: csiSnapshot.Status.RestoreSize.Value(),
Size: restoreSize,
Driver: csiSnapshot.Annotations[CSIDriverNameAnnotation],
VSCName: *csiSnapshot.Spec.Source.VolumeSnapshotContentName,
VSCName: vscName,
},
}
if pvcPVInfo := t.pvPvc.retrieve("", pvcName, pvcNS); pvcPVInfo != nil {