Merge "Provide original fault message when BFV fails" into stable/newton
This commit is contained in:
commit
b362f93999
|
@ -1594,10 +1594,14 @@ class ComputeManager(manager.Manager):
|
|||
LOG.warning(msg, instance=instance)
|
||||
raise exception.VolumeLimitExceeded()
|
||||
|
||||
except Exception:
|
||||
except Exception as ex:
|
||||
LOG.exception(_LE('Instance failed block device setup'),
|
||||
instance=instance)
|
||||
raise exception.InvalidBDM()
|
||||
# InvalidBDM will eventually result in a BuildAbortException when
|
||||
# booting from volume, and will be recorded as an instance fault.
|
||||
# Maintain the original exception message which most likely has
|
||||
# useful details which the standard InvalidBDM error message lacks.
|
||||
raise exception.InvalidBDM(six.text_type(ex))
|
||||
|
||||
def _update_instance_after_spawn(self, context, instance):
|
||||
instance.power_state = self._get_power_state(context, instance)
|
||||
|
|
|
@ -4136,6 +4136,28 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
|||
mock_prep.assert_called_once_with(self.context, self.instance,
|
||||
self.block_device_mapping)
|
||||
|
||||
@mock.patch('nova.virt.block_device.attach_block_devices',
|
||||
side_effect=exception.VolumeNotCreated('oops!'))
|
||||
def test_prep_block_device_maintain_original_error_message(self,
|
||||
mock_attach):
|
||||
"""Tests that when attach_block_devices raises an Exception, the
|
||||
re-raised InvalidBDM has the original error message which contains
|
||||
the actual details of the failure.
|
||||
"""
|
||||
bdms = objects.BlockDeviceMappingList(
|
||||
objects=[fake_block_device.fake_bdm_object(
|
||||
self.context,
|
||||
dict(source_type='image',
|
||||
destination_type='volume',
|
||||
boot_index=0,
|
||||
image_id=uuids.image_id,
|
||||
device_name='/dev/vda',
|
||||
volume_size=1))])
|
||||
ex = self.assertRaises(exception.InvalidBDM,
|
||||
self.compute._prep_block_device,
|
||||
self.context, self.instance, bdms)
|
||||
self.assertEqual('oops!', six.text_type(ex))
|
||||
|
||||
def test_failed_bdm_prep_from_delete_raises_unexpected(self):
|
||||
with test.nested(
|
||||
mock.patch.object(self.compute,
|
||||
|
|
Loading…
Reference in New Issue