From aaeb047e40d88debfc789c938a45bbf3acf2611c Mon Sep 17 00:00:00 2001 From: okozachenko1203 Date: Tue, 17 May 2022 02:28:15 +1000 Subject: [PATCH] Add exception for failures to delete pre-failed backups --- staffeln/conductor/backup.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/staffeln/conductor/backup.py b/staffeln/conductor/backup.py index 9d3ee0e..70db2b5 100755 --- a/staffeln/conductor/backup.py +++ b/staffeln/conductor/backup.py @@ -209,7 +209,10 @@ def hard_remove_volume_backup(self, backup_object): except OpenstackSDKException as e: LOG.info( - _("Backup %s deletion failed." "%s" % (backup_object.backup_id, str(e))) + _( + "Backup %s deletion failed. Need to delete manually." + "%s" % (backup_object.backup_id, str(e)) + ) ) # TODO(Alex): Add it into the notification queue @@ -340,7 +343,7 @@ def process_pre_failed_backup(self, task): "The backup creation for the volume %s was prefailed." % task.volume_id ) self.result.add_failed_backup(task.project_id, task.volume_id, reason) - # LOG.error(reason) + LOG.warn(reason) # 2. remove failed task from the task queue task.delete_queue() @@ -348,9 +351,17 @@ def process_failed_backup(self, task): # 1. notify via email reason = _("The status of backup for the volume %s is error." % task.volume_id) self.result.add_failed_backup(task.project_id, task.volume_id, reason) - LOG.error(reason) + LOG.warn(reason) # 2. delete backup generator - self.openstacksdk.delete_backup(uuid=task.backup_id, force=True) + try: + self.openstacksdk.delete_backup(uuid=task.backup_id, force=True) + except OpenstackHttpException as ex: + LOG.error( + _( + "Failed to delete volume backup %s. %s. Need to delete manually." + % (task.backup_id, str(ex)) + ) + ) # 3. remove failed task from the task queue task.delete_queue() @@ -392,6 +403,7 @@ def check_volume_backup_status(self, queue): return if project_id not in self.project_list: self.process_non_existing_backup(queue) + return self.openstacksdk.set_project(self.project_list[project_id]) backup_gen = self.openstacksdk.get_backup(queue.backup_id)