diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 35da26303c69..ab1ae0ba02ae 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -970,8 +970,15 @@ class ComputeManager(manager.Manager): except NotImplementedError as e: LOG.debug(e, instance=instance) except exception.VirtualInterfacePlugException: - # we don't want an exception to block the init_host - LOG.exception("Vifs plug failed", instance=instance) + # NOTE(mriedem): If we get here, it could be because the vif_type + # in the cache is "binding_failed". The only way to fix that is to + # try and bind the ports again, which would be expensive here on + # host startup. We could add a check to _heal_instance_info_cache + # to handle this, but probably only if the instance task_state is + # None. + LOG.exception('Virtual interface plugging failed for instance. ' + 'The port binding:host_id may need to be manually ' + 'updated.', instance=instance) self._set_instance_obj_error_state(context, instance) return diff --git a/nova/network/os_vif_util.py b/nova/network/os_vif_util.py index fb5d3c75a55e..4c61157b7b4f 100644 --- a/nova/network/os_vif_util.py +++ b/nova/network/os_vif_util.py @@ -462,6 +462,20 @@ def _nova_to_osvif_vif_hostdev_physical(vif): raise NotImplementedError() +# VIF_TYPE_BINDING_FAILED = 'binding_failed' +def _nova_to_osvif_vif_binding_failed(vif): + """Special handler for the "binding_failed" vif type. + + The "binding_failed" vif type indicates port binding to a host failed + and we are trying to plug the vifs again, which will fail because we + do not know the actual real vif type, like ovs, bridge, etc. We raise + NotImplementedError to indicate to the caller that we cannot handle + this type of vif rather than the generic "Unsupported VIF type" error + in nova_to_osvif_vif. + """ + raise NotImplementedError() + + def nova_to_osvif_vif(vif): """Convert a Nova VIF model to an os-vif object diff --git a/nova/tests/unit/network/test_os_vif_util.py b/nova/tests/unit/network/test_os_vif_util.py index 0aadf14e5999..8b87a7698d14 100644 --- a/nova/tests/unit/network/test_os_vif_util.py +++ b/nova/tests/unit/network/test_os_vif_util.py @@ -14,6 +14,7 @@ from os_vif import objects as osv_objects from os_vif.objects import fields as os_vif_fields +import six from nova import exception from nova.network import model @@ -972,9 +973,20 @@ class OSVIFUtilTestCase(test.NoDBTestCase): subnets=[]), ) - self.assertRaises(exception.NovaException, - os_vif_util.nova_to_osvif_vif, - vif) + ex = self.assertRaises(exception.NovaException, + os_vif_util.nova_to_osvif_vif, vif) + self.assertIn('Unsupported VIF type wibble', six.text_type(ex)) + + def test_nova_to_osvif_vif_binding_failed(self): + vif = model.VIF( + id="dc065497-3c8d-4f44-8fb4-e1d33c16a536", + type="binding_failed", + address="22:52:25:62:e2:aa", + network=model.Network( + id="b82c1929-051e-481d-8110-4669916c7915", + label="Demo Net", + subnets=[]),) + self.assertIsNone(os_vif_util.nova_to_osvif_vif(vif)) def test_nova_to_osvif_vhostuser_vrouter(self): vif = model.VIF(