Merge "Handle Invalid exceptions as expected in attach_interface"
This commit is contained in:
@@ -6285,6 +6285,20 @@ class ComputeManager(manager.Manager):
|
||||
{'port_id': port_id, 'error': ex},
|
||||
instance=instance)
|
||||
|
||||
# TODO(mriedem): There are likely race failures which can result in
|
||||
# NotFound and QuotaError exceptions getting traced as well.
|
||||
@messaging.expected_exceptions(
|
||||
# Do not log a traceback for user errors. We use Invalid generically
|
||||
# since this method can raise lots of different exceptions:
|
||||
# AttachInterfaceNotSupported
|
||||
# NetworkInterfaceTaggedAttachNotSupported
|
||||
# NetworkAmbiguous
|
||||
# PortNotUsable
|
||||
# PortInUse
|
||||
# PortNotUsableDNS
|
||||
# AttachSRIOVPortNotSupported
|
||||
# NetworksWithQoSPolicyNotSupported
|
||||
exception.Invalid)
|
||||
@wrap_exception()
|
||||
@wrap_instance_event(prefix='compute')
|
||||
@wrap_instance_fault
|
||||
|
@@ -1572,12 +1572,12 @@ class ConfigDriveNotFound(NotFound):
|
||||
"does not exist.")
|
||||
|
||||
|
||||
class InterfaceAttachFailed(Invalid):
|
||||
class InterfaceAttachFailed(NovaException):
|
||||
msg_fmt = _("Failed to attach network adapter device to "
|
||||
"%(instance_uuid)s")
|
||||
|
||||
|
||||
class InterfaceAttachFailedNoNetwork(InterfaceAttachFailed):
|
||||
class InterfaceAttachFailedNoNetwork(Invalid):
|
||||
msg_fmt = _("No specific network was requested and none are available "
|
||||
"for project '%(project_id)s'.")
|
||||
|
||||
|
@@ -10473,10 +10473,13 @@ class ComputeAPITestCase(BaseTestCase):
|
||||
with mock.patch.dict(self.compute.driver.capabilities,
|
||||
supports_attach_interface=True,
|
||||
supports_tagged_attach_interface=False):
|
||||
self.assertRaises(
|
||||
exception.NetworkInterfaceTaggedAttachNotSupported,
|
||||
expected_exception = self.assertRaises(
|
||||
messaging.ExpectedException,
|
||||
self.compute.attach_interface, self.context, instance,
|
||||
'fake-network-id', 'fake-port-id', 'fake-req-ip', tag='foo')
|
||||
wrapped_exc = expected_exception.exc_info[1]
|
||||
self.assertIsInstance(
|
||||
wrapped_exc, exception.NetworkInterfaceTaggedAttachNotSupported)
|
||||
|
||||
def test_attach_interface_failed(self):
|
||||
new_type = flavors.get_flavor_by_flavor_id('4')
|
||||
|
Reference in New Issue
Block a user