From 2598e7a932f2226a9dd9ae34b3a373f0708b3360 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 31 Oct 2023 10:02:22 +0800 Subject: [PATCH] fix(backup): backupInfo might be nil The backupInfo would be nil when we try to pull the backups from remote backup target. Ref: 6998 Signed-off-by: James Lu (cherry picked from commit b810121b33789d145f220bfd0e41102a7801a354) --- controller/backup_volume_controller.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controller/backup_volume_controller.go b/controller/backup_volume_controller.go index ab5d6c319d..525078c85e 100644 --- a/controller/backup_volume_controller.go +++ b/controller/backup_volume_controller.go @@ -325,8 +325,10 @@ func (bvc *BackupVolumeController) reconcile(backupVolumeName string) (err error "backupvolume": backupVolumeName, "backuptarget": backupURL}).Warnf("Failed to get backupInfo from remote backup target") } else { - if accessMode, exist := backupInfo.Labels[types.GetLonghornLabelKey(types.LonghornLabelVolumeAccessMode)]; exist { - backupLabelMap[types.GetLonghornLabelKey(types.LonghornLabelVolumeAccessMode)] = accessMode + if backupInfo != nil && backupInfo.Labels != nil { + if accessMode, exist := backupInfo.Labels[types.GetLonghornLabelKey(types.LonghornLabelVolumeAccessMode)]; exist { + backupLabelMap[types.GetLonghornLabelKey(types.LonghornLabelVolumeAccessMode)] = accessMode + } } }