Update restore controller logic for restore deletion

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(尹文开) <yinw@vmware.com>
This commit is contained in:
Wenkai Yin(尹文开)
2023-09-05 15:13:37 +08:00
parent 8cb04d4f69
commit da6ac026d1
2 changed files with 5 additions and 5 deletions

View File

@@ -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()