Merge pull request #7438 from Lyndon-Li/batch-delete-snapshot

Issue 7281: batch delete snapshot
This commit is contained in:
lyndon-li
2024-03-27 13:31:07 +08:00
committed by GitHub
14 changed files with 610 additions and 73 deletions

View File

@@ -122,19 +122,30 @@ func getVolumeBackupInfoForPod(podVolumeBackups []*velerov1api.PodVolumeBackup,
}
// GetSnapshotIdentifier returns the snapshots represented by SnapshotIdentifier for the given PVBs
func GetSnapshotIdentifier(podVolumeBackups *velerov1api.PodVolumeBackupList) []repository.SnapshotIdentifier {
var res []repository.SnapshotIdentifier
func GetSnapshotIdentifier(podVolumeBackups *velerov1api.PodVolumeBackupList) map[string][]repository.SnapshotIdentifier {
res := map[string][]repository.SnapshotIdentifier{}
for _, item := range podVolumeBackups.Items {
if item.Status.SnapshotID == "" {
continue
}
res = append(res, repository.SnapshotIdentifier{
if res[item.Spec.Pod.Namespace] == nil {
res[item.Spec.Pod.Namespace] = []repository.SnapshotIdentifier{}
}
snapshots := res[item.Spec.Pod.Namespace]
snapshots = append(snapshots, repository.SnapshotIdentifier{
VolumeNamespace: item.Spec.Pod.Namespace,
BackupStorageLocation: item.Spec.BackupStorageLocation,
SnapshotID: item.Status.SnapshotID,
RepositoryType: getRepositoryType(item.Spec.UploaderType),
UploaderType: item.Spec.UploaderType,
Source: item.Status.Path,
RepoIdentifier: item.Spec.RepoIdentifier,
})
res[item.Spec.Pod.Namespace] = snapshots
}
return res