From da6ac026d160582a0da87a11cf7533d4e8583d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wenkai=20Yin=28=E5=B0=B9=E6=96=87=E5=BC=80=29?= Date: Tue, 5 Sep 2023 15:13:37 +0800 Subject: [PATCH] Update restore controller logic for restore deletion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Skip deleting the restore files from storage if the backup/BSL is not found 2. Allow deleting the restore files from storage even though the BSL is readonly Signed-off-by: Wenkai Yin(尹文开) --- changelogs/unreleased/6770-ywk253100 | 1 + pkg/controller/restore_controller.go | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 changelogs/unreleased/6770-ywk253100 diff --git a/changelogs/unreleased/6770-ywk253100 b/changelogs/unreleased/6770-ywk253100 new file mode 100644 index 0000000000..6e55ffcd49 --- /dev/null +++ b/changelogs/unreleased/6770-ywk253100 @@ -0,0 +1 @@ +Update restore controller logic for restore deletion \ No newline at end of file diff --git a/pkg/controller/restore_controller.go b/pkg/controller/restore_controller.go index 076baf85cb..244aaf0036 100644 --- a/pkg/controller/restore_controller.go +++ b/pkg/controller/restore_controller.go @@ -671,14 +671,13 @@ func (r *restoreReconciler) deleteExternalResources(restore *api.Restore) error backupInfo, err := r.fetchBackupInfo(restore.Spec.BackupName) if err != nil { + if apierrors.IsNotFound(err) { + r.logger.Errorf("got not found error: %v, skip deleting the restore files in object storage", err) + return nil + } return errors.Wrap(err, fmt.Sprintf("can't get backup info, backup: %s", restore.Spec.BackupName)) } - // if storage locations is read-only, skip deletion - if backupInfo.location.Spec.AccessMode == api.BackupStorageLocationAccessModeReadOnly { - return nil - } - // delete restore files in object storage pluginManager := r.newPluginManager(r.logger) defer pluginManager.CleanupClients()