Include call to delete_subnet from delete_network at DB level

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
This commit is contained in:
Edgar Magana
2013-08-29 16:28:26 -07:00
parent 12324cbde1
commit 79b32b6a31
3 changed files with 9 additions and 5 deletions

View File

@@ -954,8 +954,10 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
self._delete_port(context, port['id']) self._delete_port(context, port['id'])
# clean up subnets # clean up subnets
subnets_qry = context.session.query(models_v2.Subnet) subnets = self._get_subnets_by_network(context, id)
subnets_qry.filter_by(network_id=id).delete() for subnet in subnets:
self.delete_subnet(context, subnet['id'])
context.session.delete(network) context.session.delete(network)
def get_network(self, context, id, fields=None): def get_network(self, context, id, fields=None):

View File

@@ -863,8 +863,6 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
self._send_update_network(orig_net, context) self._send_update_network(orig_net, context)
return new_subnet return new_subnet
# NOTE(kevinbenton): workaround for eventlet/mysql deadlock
@utils.synchronized('bsn-port-barrier')
@put_context_in_serverpool @put_context_in_serverpool
def delete_subnet(self, context, id): def delete_subnet(self, context, id):
LOG.debug(_("NeutronRestProxyV2: delete_subnet() called")) LOG.debug(_("NeutronRestProxyV2: delete_subnet() called"))

View File

@@ -2648,10 +2648,14 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
res = self._create_network(fmt=self.fmt, name='net', res = self._create_network(fmt=self.fmt, name='net',
admin_state_up=True) admin_state_up=True)
network = self.deserialize(self.fmt, res) 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']) req = self.new_delete_request('networks', network['network']['id'])
res = req.get_response(self.api) res = req.get_response(self.api)
self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code) 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): def test_create_subnet_bad_tenant(self):
with self.network() as network: with self.network() as network: