Skip to content

Commit

Permalink
Merge pull request #48 from vexxhost/fix-process_failed_backup
Browse files Browse the repository at this point in the history
Add exception for failures to delete pre-failed backups
  • Loading branch information
okozachenko1203 authored May 16, 2022
2 parents 34da944 + aaeb047 commit 02d8a91
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions staffeln/conductor/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -340,17 +343,25 @@ 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()

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

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 02d8a91

Please sign in to comment.