Compute: Catch binding failed exception while init host
While compute starts it will init all instances, if an exception is raised from one instance (e.g NovaException during plug_vifs), then the compute process exits unexpectedly because of this unhandled exception. This commit changes the NovaException to more appropriate VirtualInterfacePlugException and catches it during init host, as well as the instance is set to error state, with this change the compute process can be started normally even if this VirtualInterfacePlugException is raised. Closes-bug: #1324041 Change-Id: Ia584dba66affb86787e3069df19bd17b89cb5c49
This commit is contained in:
parent
3ad52a79d8
commit
16ac50b1e7
|
@ -981,6 +981,12 @@ class ComputeManager(manager.Manager):
|
|||
self.driver.plug_vifs(instance, net_info)
|
||||
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(_LE("Vifs plug failed"), instance=instance)
|
||||
self._set_instance_error_state(context, instance)
|
||||
return
|
||||
|
||||
if instance.task_state == task_states.RESIZE_MIGRATING:
|
||||
# We crashed during resize/migration, so roll back for safety
|
||||
try:
|
||||
|
|
|
@ -160,6 +160,10 @@ class VirtualInterfaceMacAddressException(NovaException):
|
|||
"unique mac address failed")
|
||||
|
||||
|
||||
class VirtualInterfacePlugException(NovaException):
|
||||
msg_fmt = _("Virtual interface plugin failed")
|
||||
|
||||
|
||||
class GlanceConnectionFailed(NovaException):
|
||||
msg_fmt = _("Connection to glance host %(host)s:%(port)s failed: "
|
||||
"%(reason)s")
|
||||
|
|
|
@ -392,6 +392,30 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
self.mox.VerifyAll()
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_init_instance_with_binding_failed_vif_type(self):
|
||||
# this instance will plug a 'binding_failed' vif
|
||||
instance = fake_instance.fake_instance_obj(
|
||||
self.context,
|
||||
uuid='fake-uuid',
|
||||
info_cache=None,
|
||||
power_state=power_state.RUNNING,
|
||||
vm_state=vm_states.ACTIVE,
|
||||
task_state=None,
|
||||
expected_attrs=['info_cache'])
|
||||
|
||||
with contextlib.nested(
|
||||
mock.patch.object(context, 'get_admin_context',
|
||||
return_value=self.context),
|
||||
mock.patch.object(compute_utils, 'get_nw_info_for_instance',
|
||||
return_value=network_model.NetworkInfo()),
|
||||
mock.patch.object(self.compute.driver, 'plug_vifs',
|
||||
side_effect=exception.VirtualInterfacePlugException(
|
||||
"Unexpected vif_type=binding_failed")),
|
||||
mock.patch.object(self.compute, '_set_instance_error_state')
|
||||
) as (get_admin_context, get_nw_info, plug_vifs, set_error_state):
|
||||
self.compute._init_instance(self.context, instance)
|
||||
set_error_state.assert_called_once_with(self.context, instance)
|
||||
|
||||
def test_init_instance_failed_resume_sets_error(self):
|
||||
instance = fake_instance.fake_instance_obj(
|
||||
self.context,
|
||||
|
|
|
@ -886,7 +886,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
|||
ports = ironicclient.call("node.list_ports", node.uuid)
|
||||
|
||||
if len(network_info) > len(ports):
|
||||
raise exception.NovaException(_(
|
||||
raise exception.VirtualInterfacePlugException(_(
|
||||
"Ironic node: %(id)s virtual to physical interface count"
|
||||
" missmatch"
|
||||
" (Vif count: %(vif_count)d, Pif count: %(pif_count)d)")
|
||||
|
|
|
@ -531,14 +531,15 @@ class LibvirtGenericVIFDriver(object):
|
|||
'vif': vif})
|
||||
|
||||
if vif_type is None:
|
||||
raise exception.NovaException(
|
||||
raise exception.VirtualInterfacePlugException(
|
||||
_("vif_type parameter must be present "
|
||||
"for this vif_driver implementation"))
|
||||
vif_slug = self._normalize_vif_type(vif_type)
|
||||
func = getattr(self, 'plug_%s' % vif_slug, None)
|
||||
if not func:
|
||||
raise exception.NovaException(
|
||||
_("Unexpected vif_type=%s") % vif_type)
|
||||
raise exception.VirtualInterfacePlugException(
|
||||
_("Plug vif failed because of unexpected "
|
||||
"vif_type=%s") % vif_type)
|
||||
func(instance, vif)
|
||||
|
||||
def unplug_bridge(self, instance, vif):
|
||||
|
|
Loading…
Reference in New Issue