Handle NotImplementedError in _process_instance_vif_deleted_event
The Ironic virt driver does not support attach/detach of VIFs (yet) so when Neutron sends an asynchronous event back to Nova that VIFs were unplugged on instance delete, we do not need to trace all over the logs when the Ironic driver does not implement detach_interface(). Change-Id: I6f6533322c1179b3396e56b37c4f3f4228d8da01 Closes-Bug: #1660317
This commit is contained in:
parent
cbc84b3cff
commit
00c0830c3e
|
@ -6786,6 +6786,10 @@ class ComputeManager(manager.Manager):
|
|||
nw_info=network_info)
|
||||
try:
|
||||
self.driver.detach_interface(context, instance, vif)
|
||||
except NotImplementedError:
|
||||
# Not all virt drivers support attach/detach of interfaces
|
||||
# yet (like Ironic), so just ignore this.
|
||||
pass
|
||||
except exception.NovaException as ex:
|
||||
LOG.warning(_LW("Detach interface failed, "
|
||||
"port_id=%(port_id)s, reason: %(msg)s"),
|
||||
|
|
|
@ -2161,6 +2161,31 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
inst_obj, vif2)
|
||||
do_test()
|
||||
|
||||
def test_process_instance_vif_deleted_event_not_implemented_error(self):
|
||||
"""Tests the case where driver.detach_interface raises
|
||||
NotImplementedError.
|
||||
"""
|
||||
vif = fake_network_cache_model.new_vif()
|
||||
nw_info = network_model.NetworkInfo([vif])
|
||||
info_cache = objects.InstanceInfoCache(network_info=nw_info,
|
||||
instance_uuid=uuids.instance)
|
||||
inst_obj = objects.Instance(id=3, uuid=uuids.instance,
|
||||
info_cache=info_cache)
|
||||
|
||||
@mock.patch.object(manager.base_net_api,
|
||||
'update_instance_cache_with_nw_info')
|
||||
@mock.patch.object(self.compute.driver, 'detach_interface',
|
||||
side_effect=NotImplementedError)
|
||||
def do_test(detach_interface, update_instance_cache_with_nw_info):
|
||||
self.compute._process_instance_vif_deleted_event(
|
||||
self.context, inst_obj, vif['id'])
|
||||
update_instance_cache_with_nw_info.assert_called_once_with(
|
||||
self.compute.network_api, self.context, inst_obj, nw_info=[])
|
||||
detach_interface.assert_called_once_with(
|
||||
self.context, inst_obj, vif)
|
||||
|
||||
do_test()
|
||||
|
||||
def test_external_instance_event(self):
|
||||
instances = [
|
||||
objects.Instance(id=1, uuid=uuids.instance_1),
|
||||
|
|
Loading…
Reference in New Issue