Merge "Improve Subnet delete performance"

This commit is contained in:
Zuul 2021-06-05 00:57:35 +00:00 committed by Gerrit Code Review
commit f7bac83f85
2 changed files with 5 additions and 4 deletions

View File

@ -1056,7 +1056,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
with db_api.exc_to_retry(sql_exc.IntegrityError), \ with db_api.exc_to_retry(sql_exc.IntegrityError), \
db_api.CONTEXT_WRITER.using(context): db_api.CONTEXT_WRITER.using(context):
registry.notify(resources.SUBNET, events.PRECOMMIT_DELETE, registry.notify(resources.SUBNET, events.PRECOMMIT_DELETE,
self, context=context, subnet_id=subnet.id) self, context=context, subnet_id=subnet.id,
subnet_obj=subnet)
subnet.delete() subnet.delete()
# Delete related ipam subnet manually, # Delete related ipam subnet manually,
# since there is no FK relationship # since there is no FK relationship

View File

@ -1349,11 +1349,11 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
@registry.receives(resources.SUBNET, [events.PRECOMMIT_DELETE], priority=0) @registry.receives(resources.SUBNET, [events.PRECOMMIT_DELETE], priority=0)
def _subnet_delete_precommit_handler(self, rtype, event, trigger, def _subnet_delete_precommit_handler(self, rtype, event, trigger,
context, subnet_id, **kwargs): context, subnet_id, **kwargs):
subnet_obj = self._get_subnet_object(context, subnet_id) subnet_obj = (kwargs.get('subnet_obj') or
self._get_subnet_object(context, subnet_id))
subnet = self._make_subnet_dict(subnet_obj, context=context) subnet = self._make_subnet_dict(subnet_obj, context=context)
network = self.get_network(context, subnet['network_id'])
mech_context = driver_context.SubnetContext(self, context, mech_context = driver_context.SubnetContext(self, context,
subnet, network) subnet, network=None)
# TODO(kevinbenton): move this mech context into something like # TODO(kevinbenton): move this mech context into something like
# a 'delete context' so it's not polluting the real context object # a 'delete context' so it's not polluting the real context object
setattr(context, '_mech_context', mech_context) setattr(context, '_mech_context', mech_context)