Merge "Handle binding_failed vif plug errors on compute restart" into stable/queens

This commit is contained in:
Zuul 2019-01-26 12:33:59 +00:00 committed by Gerrit Code Review
commit c559ee1d17
3 changed files with 38 additions and 5 deletions

View File

@ -961,8 +961,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

View File

@ -468,6 +468,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

View File

@ -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
@ -988,9 +989,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(