Avoid deleting parent backup failed caused by 404

Catch NotFound exception in for loop, to avoid dropping out
while deleting parent backup that has multiple children backups.

Change-Id: Idab9fc8d6c09b0b58015b0b9fdf99811d075191f
Closes-bug: #1718572
This commit is contained in:
Fan Zhang 2017-09-21 13:51:26 +08:00 committed by yangzhenyu
parent d7b773d2b0
commit 6318e74928
1 changed files with 4 additions and 1 deletions

View File

@ -265,7 +265,10 @@ class Backup(object):
query = DBBackup.query()
query = query.filter_by(parent_id=backup_id, deleted=False)
for child in query.all():
cls.delete(context, child.id)
try:
cls.delete(context, child.id)
except exception.NotFound:
LOG.exception(_("Backup %s cannot be found."), backup_id)
def _delete_resources():
backup = cls.get_by_id(context, backup_id)