Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 56c4a69

Browse files
committed
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
1 parent 64d6ba3 commit 56c4a69

File tree

3 files changed

+40
-0
lines changed
  • nova
    • compute
      • manager.py
    • tests/unit/compute
      • test_compute_mgr.py
  • releasenotes/notes
    • fix-failure-prep-block-d7e1cad6d3910502.yaml

3 files changed

+40
-0
lines changed

nova/compute/manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,6 +2945,7 @@ def _build_resources(self, context, instance, requested_networks,
29452945
self._build_resources_cleanup(instance, network_info)
29462946
except (exception.UnexpectedTaskStateError,
29472947
exception.InstanceUnacceptable,
2948+
exception.ExternalNetworkAttachForbidden,
29482949
exception.OverQuota, exception.InvalidBDM) as e:
29492950
self._build_resources_cleanup(instance, network_info)
29502951
raise exception.BuildAbortException(instance_uuid=instance.uuid,

nova/tests/unit/compute/test_compute_mgr.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8534,6 +8534,36 @@ def _test_accel_build_resources(self, accel_uuids, network_arqs,
85348534
mock.ANY, network_arqs)
85358535
return resources
85368536

8537+
@mock.patch.object(virt_driver.ComputeDriver,
8538+
'prepare_for_spawn')
8539+
@mock.patch.object(nova.compute.manager.ComputeManager,
8540+
'_build_networks_for_instance')
8541+
@mock.patch.object(virt_driver.ComputeDriver,
8542+
'prepare_networks_before_block_device_mapping')
8543+
def test_build_resources_prepnets_exception(
8544+
self, mock_prep_net, mock_build_net, mock_prep_spawn):
8545+
8546+
args = (self.context, self.instance, self.requested_networks,
8547+
self.security_groups, self.image, self.block_device_mapping,
8548+
self.resource_provider_mapping, [])
8549+
8550+
mock_prep_net.side_effect = exception.ExternalNetworkAttachForbidden(
8551+
network_uuid=uuids.network_id)
8552+
8553+
resources = self.compute._build_resources(*args)
8554+
e = self.assertRaises(
8555+
exception.BuildAbortException,
8556+
resources.__enter__
8557+
)
8558+
self.assertIn(
8559+
"It is not allowed to create an interface on external network",
8560+
str(e)
8561+
)
8562+
8563+
mock_build_net.assert_called_once_with(self.context, self.instance,
8564+
self.requested_networks, mock.ANY,
8565+
mock.ANY, mock.ANY)
8566+
85378567
@mock.patch.object(nova.compute.manager.ComputeManager,
85388568
'_get_bound_arq_resources')
85398569
def test_accel_build_resources_no_device_profile(self, mock_get_arqs):

releasenotes/notes/fix-failure-prep-block-d7e1cad6d3910502.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
fixes:
3+
- |
4+
Fixes `bug 2137673`_ where details about the fact that the user specified
5+
an incorrect configuration by requesting to attach to an external network are
6+
masked by "Failure prepping block device" since they do not have access to
7+
the whole backtrace.
8+
9+
.. _bug 2137673: https://bugs.launchpad.net/nova/+bug/2137673

0 commit comments

Comments
(0)