From afd1983680aea739ef0e4b0ff2c07ab09c4a86fb Mon Sep 17 00:00:00 2001 From: armando-migliaccio Date: Tue, 1 Sep 2015 15:45:50 -0700 Subject: [PATCH] Catch errors on 'port not found' while deleting subnet In some circumstances (like the one triggered by the test_dhcp_ipv6 testcase) calls to deleting a port and calls to deleting subnets can happen in straight sequence. If this happens the execution of the operations can interleave leading to the subnet deletion to fail because the port has already gone. This patch ensures a missing port is handled correctly. The method delete_subnet is ginormous and hence impossible to test at a unit level without proper refactoring. That can happen with a follow-up patch. Closes-bug: #1490832 Change-Id: I80c3733c93b2b66c2a1c4bc3bc24272afdd88b1f --- neutron/plugins/ml2/plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index dc5446b6a..9ba545018 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -947,7 +947,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, break for a in allocated: - if a.port_id: + if a.port: # calling update_port() for each allocation to remove the # IP from the port and call the MechanismDrivers data = {attributes.PORT: @@ -957,6 +957,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, if ip.subnet_id != id]}} try: self.update_port(context, a.port_id, data) + except exc.PortNotFound: + LOG.debug("Port %s deleted concurrently", a.port_id) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Exception deleting fixed_ip " -- 2.45.2