return error about external network to the user on build failure
Instead of masking the error message with "Failure prepping block device" when the user requests an invalid configuration, return the actual error message to the user. Closes-Bug: 2137673 Change-Id: If12555da64ccba2649a19ee6ccbdac0e888e6ad6 Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
This commit is contained in:
@@ -2945,6 +2945,7 @@ class ComputeManager(manager.Manager):
|
||||
self._build_resources_cleanup(instance, network_info)
|
||||
except (exception.UnexpectedTaskStateError,
|
||||
exception.InstanceUnacceptable,
|
||||
exception.ExternalNetworkAttachForbidden,
|
||||
exception.OverQuota, exception.InvalidBDM) as e:
|
||||
self._build_resources_cleanup(instance, network_info)
|
||||
raise exception.BuildAbortException(instance_uuid=instance.uuid,
|
||||
|
||||
@@ -8534,6 +8534,36 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
||||
mock.ANY, network_arqs)
|
||||
return resources
|
||||
|
||||
@mock.patch.object(virt_driver.ComputeDriver,
|
||||
'prepare_for_spawn')
|
||||
@mock.patch.object(nova.compute.manager.ComputeManager,
|
||||
'_build_networks_for_instance')
|
||||
@mock.patch.object(virt_driver.ComputeDriver,
|
||||
'prepare_networks_before_block_device_mapping')
|
||||
def test_build_resources_prepnets_exception(
|
||||
self, mock_prep_net, mock_build_net, mock_prep_spawn):
|
||||
|
||||
args = (self.context, self.instance, self.requested_networks,
|
||||
self.security_groups, self.image, self.block_device_mapping,
|
||||
self.resource_provider_mapping, [])
|
||||
|
||||
mock_prep_net.side_effect = exception.ExternalNetworkAttachForbidden(
|
||||
network_uuid=uuids.network_id)
|
||||
|
||||
resources = self.compute._build_resources(*args)
|
||||
e = self.assertRaises(
|
||||
exception.BuildAbortException,
|
||||
resources.__enter__
|
||||
)
|
||||
self.assertIn(
|
||||
"It is not allowed to create an interface on external network",
|
||||
str(e)
|
||||
)
|
||||
|
||||
mock_build_net.assert_called_once_with(self.context, self.instance,
|
||||
self.requested_networks, mock.ANY,
|
||||
mock.ANY, mock.ANY)
|
||||
|
||||
@mock.patch.object(nova.compute.manager.ComputeManager,
|
||||
'_get_bound_arq_resources')
|
||||
def test_accel_build_resources_no_device_profile(self, mock_get_arqs):
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes `bug 2137673`_ where details about the fact that the user specified
|
||||
an incorrect configuration by requesting to attach to an external network are
|
||||
masked by "Failure prepping block device" since they do not have access to
|
||||
the whole backtrace.
|
||||
|
||||
.. _bug 2137673: https://bugs.launchpad.net/nova/+bug/2137673
|
||||
Reference in New Issue
Block a user