Merge "Move update_task_state out of try/except" into stable/queens

This commit is contained in:
Zuul 2018-05-21 03:25:44 +00:00 committed by Gerrit Code Review
commit 75d31a8a4f
2 changed files with 11 additions and 2 deletions

View File

@ -20926,6 +20926,14 @@ class LibvirtSnapshotTests(_BaseSnapshotTests):
self._test_snapshot(disk_format='qcow2',
extra_properties=extra_properties)
@mock.patch.object(libvirt_driver.LOG, 'exception')
def test_snapshot_update_task_state_failed(self, mock_exception):
res = [None, exception.InstanceNotFound(instance_id='foo')]
self.mock_update_task_state.side_effect = res
self.assertRaises(exception.InstanceNotFound, self._test_snapshot,
disk_format='qcow2')
self.assertFalse(mock_exception.called)
@mock.patch.object(host.Host, 'get_guest')
@mock.patch.object(host.Host, 'write_instance_config')
def test_failing_domain_not_found(self, mock_write_config, mock_get_guest):

View File

@ -1909,9 +1909,10 @@ class LibvirtDriver(driver.ComputeDriver):
update_task_state(task_state=task_states.IMAGE_PENDING_UPLOAD)
update_task_state(task_state=task_states.IMAGE_UPLOADING,
expected_state=task_states.IMAGE_PENDING_UPLOAD)
try:
update_task_state(task_state=task_states.IMAGE_UPLOADING,
expected_state=task_states.IMAGE_PENDING_UPLOAD)
metadata['location'] = root_disk.direct_snapshot(
context, snapshot_name, image_format, image_id,
instance.image_ref)