Catch exceptions from backup runner
The backup runner context manager may throw BackupErrors. The backupagent currently only checks for the success of the storage save action and any exceptions, but not those from the runner __enter__/__exit__ methods. This issue was discovered when fixing backup unittests in change: 312611 The unittests assert that the backup would be marked as FAILED, but was marked as COMPLETED instead. This patch just moves the 'with clause' of the backup runner to the try-except block to intercept any exceptions originating from the backup procedures. Change-Id: I27d0cf1b9a174ca69eb82d26f14a4c0d03f75382 Partial-Bug: 1544522
This commit is contained in:
parent
c45eb67018
commit
3edcd5cdcf
@ -76,9 +76,9 @@ class BackupAgent(object):
|
|||||||
**backup_state)
|
**backup_state)
|
||||||
LOG.debug("Updated state for %s to %s.", backup_id, backup_state)
|
LOG.debug("Updated state for %s to %s.", backup_id, backup_state)
|
||||||
|
|
||||||
with runner(filename=backup_id, extra_opts=extra_opts,
|
try:
|
||||||
**parent_metadata) as bkup:
|
with runner(filename=backup_id, extra_opts=extra_opts,
|
||||||
try:
|
**parent_metadata) as bkup:
|
||||||
LOG.debug("Starting backup %s.", backup_id)
|
LOG.debug("Starting backup %s.", backup_id)
|
||||||
success, note, checksum, location = storage.save(
|
success, note, checksum, location = storage.save(
|
||||||
bkup.manifest,
|
bkup.manifest,
|
||||||
@ -112,18 +112,18 @@ class BackupAgent(object):
|
|||||||
|
|
||||||
return meta
|
return meta
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception(
|
LOG.exception(
|
||||||
_("Error saving backup: %(backup_id)s.") % backup_state)
|
_("Error saving backup: %(backup_id)s.") % backup_state)
|
||||||
backup_state.update({'state': BackupState.FAILED})
|
backup_state.update({'state': BackupState.FAILED})
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
LOG.info(_("Completed backup %(backup_id)s.") % backup_state)
|
LOG.info(_("Completed backup %(backup_id)s.") % backup_state)
|
||||||
conductor.update_backup(CONF.guest_id,
|
conductor.update_backup(CONF.guest_id,
|
||||||
sent=timeutils.float_utcnow(),
|
sent=timeutils.float_utcnow(),
|
||||||
**backup_state)
|
**backup_state)
|
||||||
LOG.debug("Updated state for %s to %s.",
|
LOG.debug("Updated state for %s to %s.",
|
||||||
backup_id, backup_state)
|
backup_id, backup_state)
|
||||||
|
|
||||||
def execute_backup(self, context, backup_info,
|
def execute_backup(self, context, backup_info,
|
||||||
runner=RUNNER, extra_opts=EXTRA_OPTS,
|
runner=RUNNER, extra_opts=EXTRA_OPTS,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user