Skip to content

Commit

Permalink
fix(backup): modify API for the Action backupList
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 5411

Signed-off-by: James Lu <[email protected]>
  • Loading branch information
mantissahz authored and derekbit committed Dec 23, 2024
1 parent 7ae8f60 commit bfe760c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions csi/controller_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
15 changes: 14 additions & 1 deletion manager/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bfe760c

Please sign in to comment.