diff --git a/csi/controller_server.go b/csi/controller_server.go index 5370334e00..f0359ff67e 100644 --- a/csi/controller_server.go +++ b/csi/controller_server.go @@ -289,6 +289,7 @@ func (cs *ControllerServer) getBackupVolume(volumeName string) (*longhornclient. } } log.Debugf("cannot find backup volume with backup target %s and volume %s", vol.BackupTargetName, volumeName) + // return no error if no backup volume found as backup is not completed and backup volume is not created yet. return nil, nil } diff --git a/manager/engine.go b/manager/engine.go index 79dcff6055..1157e266a3 100644 --- a/manager/engine.go +++ b/manager/engine.go @@ -511,7 +511,20 @@ func (m *VolumeManager) ListBackupsForBackupVolumeSorted(backupVolumeName string return []*longhorn.Backup{}, err } - return m.ListBackupsForVolumeSorted(bv.Spec.VolumeName) + backupMap, err := m.ds.ListBackupsWithBackupTargetAndBackupVolumeRO(bv.Spec.BackupTargetName, bv.Spec.VolumeName) + if err != nil { + return []*longhorn.Backup{}, err + } + backupNames, err := util.SortKeys(backupMap) + if err != nil { + return []*longhorn.Backup{}, err + } + backups := make([]*longhorn.Backup, len(backupMap)) + for i, backupName := range backupNames { + backups[i] = backupMap[backupName] + } + + return backups, nil } func (m *VolumeManager) GetBackup(backupName, volumeName string) (*longhorn.Backup, error) {