]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Include call to delete_subnet from delete_network at DB level
authorEdgar Magana <emagana@gmail.com>
Thu, 29 Aug 2013 23:28:26 +0000 (16:28 -0700)
committerEdgar Magana <emagana@gmail.com>
Thu, 6 Nov 2014 21:19:10 +0000 (13:19 -0800)
Removes an extra lock in bsn plugin that causes a deadlock
when delete_subnet is invoked form delete_network, agreed
with kevinbenton to remove it
Modifies a unit test to cover this change per reviewer request
Co-author amirosh

Closes-bug: #1197176

Change-Id: Ie3414848a91cc737b16b79399ae19800545e533f

neutron/db/db_base_plugin_v2.py
neutron/plugins/bigswitch/plugin.py
neutron/tests/unit/test_db_plugin.py

index 70827c58afdf73c5b95422696503b7b4ac4a7579..bebc8b3c599e82e82aabafc5014c0f7ea490a34b 100644 (file)
@@ -954,8 +954,10 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
                 self._delete_port(context, port['id'])
 
             # clean up subnets
-            subnets_qry = context.session.query(models_v2.Subnet)
-            subnets_qry.filter_by(network_id=id).delete()
+            subnets = self._get_subnets_by_network(context, id)
+            for subnet in subnets:
+                self.delete_subnet(context, subnet['id'])
+
             context.session.delete(network)
 
     def get_network(self, context, id, fields=None):
index f7f59612716a227e668de27baf55c8e7707aa2af..d7b0b678ef86439cc53c82ee46205ed9c2de6897 100644 (file)
@@ -863,8 +863,6 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
             self._send_update_network(orig_net, context)
             return new_subnet
 
-    # NOTE(kevinbenton): workaround for eventlet/mysql deadlock
-    @utils.synchronized('bsn-port-barrier')
     @put_context_in_serverpool
     def delete_subnet(self, context, id):
         LOG.debug(_("NeutronRestProxyV2: delete_subnet() called"))
index 8a4f3ec5acd9094ea00efd8c3724293e106faed2..465183fcdd1b7cf00e6ec80810d01ed1497a4a8b 100644 (file)
@@ -2648,10 +2648,14 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
         res = self._create_network(fmt=self.fmt, name='net',
                                    admin_state_up=True)
         network = self.deserialize(self.fmt, res)
-        self._make_subnet(self.fmt, network, gateway_ip, cidr, ip_version=4)
+        subnet = self._make_subnet(self.fmt, network, gateway_ip, cidr,
+                                   ip_version=4)
         req = self.new_delete_request('networks', network['network']['id'])
         res = req.get_response(self.api)
         self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code)
+        req = self.new_show_request('subnets', subnet['subnet']['id'])
+        res = req.get_response(self.api)
+        self.assertEqual(webob.exc.HTTPNotFound.code, res.status_int)
 
     def test_create_subnet_bad_tenant(self):
         with self.network() as network: