Common Agent loop: Catch delete_port extension failures
Catch delete port extension failures like we do with normal port removal to avoid interrupting the deletion processing for other ports. Related-Bug: #1697937 Change-Id: I42d86a86965d30e14c85ce975681a6b82be41ecc
This commit is contained in:
parent
18cffe63ae
commit
5aa7192ffa
|
@ -347,9 +347,14 @@ class CommonAgentLoop(service.Service):
|
|||
else:
|
||||
LOG.debug("Device %s not defined on plugin", device)
|
||||
port_id = self._clean_network_ports(device)
|
||||
self.ext_manager.delete_port(self.context,
|
||||
{'device': device,
|
||||
'port_id': port_id})
|
||||
try:
|
||||
self.ext_manager.delete_port(self.context,
|
||||
{'device': device,
|
||||
'port_id': port_id})
|
||||
except Exception:
|
||||
LOG.exception("Error occurred while processing extensions "
|
||||
"for port removal %s", device)
|
||||
resync = True
|
||||
registry.notify(local_resources.PORT_DEVICE, events.AFTER_DELETE,
|
||||
self, context=self.context, device=device,
|
||||
port_id=port_id)
|
||||
|
|
|
@ -162,6 +162,24 @@ class TestCommonAgentLoop(base.BaseTestCase):
|
|||
self.assertTrue(ext_mgr_delete_port.called)
|
||||
self.assertNotIn(PORT_DATA, agent.network_ports[NETWORK_ID])
|
||||
|
||||
def test_treat_devices_removed_failed_extension(self):
|
||||
agent = self.agent
|
||||
devices = [DEVICE_1]
|
||||
agent.network_ports[NETWORK_ID].append(PORT_DATA)
|
||||
with mock.patch.object(agent.plugin_rpc,
|
||||
"update_device_down") as fn_udd,\
|
||||
mock.patch.object(agent.sg_agent,
|
||||
"remove_devices_filter") as fn_rdf,\
|
||||
mock.patch.object(agent.ext_manager,
|
||||
"delete_port") as ext_mgr_delete_port:
|
||||
ext_mgr_delete_port.side_effect = Exception()
|
||||
resync = agent.treat_devices_removed(devices)
|
||||
self.assertTrue(resync)
|
||||
self.assertTrue(fn_udd.called)
|
||||
self.assertTrue(fn_rdf.called)
|
||||
self.assertTrue(ext_mgr_delete_port.called)
|
||||
self.assertNotIn(PORT_DATA, agent.network_ports[NETWORK_ID])
|
||||
|
||||
def test_treat_devices_removed_with_prevent_arp_spoofing_true(self):
|
||||
agent = self.agent
|
||||
agent.prevent_arp_spoofing = True
|
||||
|
|
Loading…
Reference in New Issue