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:
@@ -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):
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user