From 61238ee0aedcfa357200a26d5c40fbe23f58a690 Mon Sep 17 00:00:00 2001 From: Lyndon-Li Date: Wed, 23 Jul 2025 11:30:32 +0800 Subject: [PATCH] issue 9077: don't block backup deletion on list VS error Signed-off-by: Lyndon-Li --- changelogs/unreleased/9100-Lyndon-Li | 1 + pkg/controller/backup_deletion_controller.go | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 changelogs/unreleased/9100-Lyndon-Li diff --git a/changelogs/unreleased/9100-Lyndon-Li b/changelogs/unreleased/9100-Lyndon-Li new file mode 100644 index 000000000..80baa45a7 --- /dev/null +++ b/changelogs/unreleased/9100-Lyndon-Li @@ -0,0 +1 @@ +Fix issue #9077, don't block backup deletion on list VS error \ No newline at end of file diff --git a/pkg/controller/backup_deletion_controller.go b/pkg/controller/backup_deletion_controller.go index 4090accc9..5a791999c 100644 --- a/pkg/controller/backup_deletion_controller.go +++ b/pkg/controller/backup_deletion_controller.go @@ -268,9 +268,7 @@ func (r *backupDeletionReconciler) Reconcile(ctx context.Context, req ctrl.Reque if err != nil { log.WithError(err).Errorf("Unable to download tarball for backup %s, skipping associated DeleteItemAction plugins", backup.Name) log.Info("Cleaning up CSI volumesnapshots") - if err := r.deleteCSIVolumeSnapshots(ctx, backup, log); err != nil { - errs = append(errs, err.Error()) - } + r.deleteCSIVolumeSnapshotsIfAny(ctx, backup, log) } else { defer closeAndRemoveFile(backupFile, r.logger) deleteCtx := &delete.Context{ @@ -507,22 +505,22 @@ func (r *backupDeletionReconciler) deleteExistingDeletionRequests(ctx context.Co return errs } -// deleteCSIVolumeSnapshots clean up the CSI snapshots created by the backup, this should be called when the backup is failed +// deleteCSIVolumeSnapshotsIfAny clean up the CSI snapshots created by the backup, this should be called when the backup is failed // when it's running, e.g. due to velero pod restart, and the backup.tar is failed to be downloaded from storage. -func (r *backupDeletionReconciler) deleteCSIVolumeSnapshots(ctx context.Context, backup *velerov1api.Backup, log logrus.FieldLogger) error { +func (r *backupDeletionReconciler) deleteCSIVolumeSnapshotsIfAny(ctx context.Context, backup *velerov1api.Backup, log logrus.FieldLogger) { vsList := snapshotv1api.VolumeSnapshotList{} if err := r.Client.List(ctx, &vsList, &client.ListOptions{ LabelSelector: labels.SelectorFromSet(map[string]string{ velerov1api.BackupNameLabel: label.GetValidName(backup.Name), }), }); err != nil { - return errors.Wrap(err, "error listing volume snapshots") + log.WithError(err).Warnf("Could not list volume snapshots, abort") + return } for _, item := range vsList.Items { vs := item csi.CleanupVolumeSnapshot(&vs, r.Client, log) } - return nil } func (r *backupDeletionReconciler) deletePodVolumeSnapshots(ctx context.Context, backup *velerov1api.Backup) []error {