Merge "Add unshelve instance error info to fault table" into stable/ocata
This commit is contained in:
commit
2e3c5feb5d
|
@ -633,7 +633,7 @@ class ComputeTaskManager(base.Base):
|
|||
context, 'get_image_info', instance.uuid):
|
||||
try:
|
||||
image = safe_image_show(context, image_id)
|
||||
except exception.ImageNotFound:
|
||||
except exception.ImageNotFound as error:
|
||||
instance.vm_state = vm_states.ERROR
|
||||
instance.save()
|
||||
|
||||
|
@ -641,6 +641,9 @@ class ComputeTaskManager(base.Base):
|
|||
'cannot be found.') % image_id
|
||||
|
||||
LOG.error(reason, instance=instance)
|
||||
compute_utils.add_instance_fault_from_exc(
|
||||
context, instance, error, sys.exc_info(),
|
||||
fault_message=reason)
|
||||
raise exception.UnshelveException(
|
||||
instance_id=instance.uuid, reason=reason)
|
||||
|
||||
|
|
|
@ -1026,7 +1026,9 @@ class _BaseTaskTestCase(object):
|
|||
|
||||
do_test()
|
||||
|
||||
def test_unshelve_offloaded_instance_glance_image_not_found(self):
|
||||
@mock.patch('nova.compute.utils.add_instance_fault_from_exc')
|
||||
def test_unshelve_offloaded_instance_glance_image_not_found(self,
|
||||
add_instance_fault_from_exc):
|
||||
shelved_image_id = "image_not_found"
|
||||
|
||||
instance = self._create_fake_instance_obj()
|
||||
|
@ -1046,10 +1048,15 @@ class _BaseTaskTestCase(object):
|
|||
system_metadata['shelved_host'] = 'fake-mini'
|
||||
system_metadata['shelved_image_id'] = shelved_image_id
|
||||
|
||||
reason = ('Unshelve attempted but the image image_not_found '
|
||||
'cannot be found.')
|
||||
|
||||
self.assertRaises(
|
||||
exc.UnshelveException,
|
||||
self.conductor_manager.unshelve_instance,
|
||||
self.context, instance)
|
||||
add_instance_fault_from_exc.assert_called_once_with(
|
||||
self.context, instance, e, mock.ANY, fault_message=reason)
|
||||
self.assertEqual(instance.vm_state, vm_states.ERROR)
|
||||
|
||||
def test_unshelve_offloaded_instance_image_id_is_none(self):
|
||||
|
|
Loading…
Reference in New Issue