]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Catch errors on 'port not found' while deleting subnet
authorarmando-migliaccio <armamig@gmail.com>
Tue, 1 Sep 2015 22:45:50 +0000 (15:45 -0700)
committerAssaf Muller <amuller@redhat.com>
Wed, 2 Sep 2015 15:28:18 +0000 (15:28 +0000)
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

index dc5446b6a3a9eba1303bbc647f95b959329e6445..9ba5450182f51895a80d1977939b4aa84b630f4c 100644 (file)
@@ -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 "