Merge "Improve Subnet update performance" into stable/ussuri

This commit is contained in:
Zuul 2021-05-08 11:32:26 +00:00 committed by Gerrit Code Review
commit 6619e9881a
3 changed files with 8 additions and 7 deletions

View File

@ -942,8 +942,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
self, **kwargs) self, **kwargs)
with db_api.CONTEXT_WRITER.using(context): with db_api.CONTEXT_WRITER.using(context):
subnet, changes = self.ipam.update_db_subnet(context, id, s, subnet, changes = self.ipam.update_db_subnet(
db_pools) context, id, s, db_pools, subnet_obj=subnet_obj)
return self._make_subnet_dict(subnet, context=context), orig return self._make_subnet_dict(subnet, context=context), orig
@property @property

View File

@ -200,7 +200,8 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
new_type.create() new_type.create()
return updated_types return updated_types
def update_db_subnet(self, context, subnet_id, s, oldpools): def update_db_subnet(self, context, subnet_id, s, oldpools,
subnet_obj=None):
changes = {} changes = {}
if "dns_nameservers" in s: if "dns_nameservers" in s:
changes['dns_nameservers'] = ( changes['dns_nameservers'] = (
@ -218,7 +219,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
changes['service_types'] = ( changes['service_types'] = (
self._update_subnet_service_types(context, subnet_id, s)) self._update_subnet_service_types(context, subnet_id, s))
subnet_obj = self._get_subnet_object(context, subnet_id) subnet_obj = subnet_obj or self._get_subnet_object(context, subnet_id)
subnet_obj.update_fields(s) subnet_obj.update_fields(s)
subnet_obj.update() subnet_obj.update()
return subnet_obj, changes return subnet_obj, changes

View File

@ -494,8 +494,8 @@ class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
self._ipam_deallocate_ips(context, ipam_driver, port, self._ipam_deallocate_ips(context, ipam_driver, port,
port['fixed_ips']) port['fixed_ips'])
def update_db_subnet(self, context, id, s, old_pools): def update_db_subnet(self, context, id, s, old_pools, subnet_obj=None):
subnet = obj_subnet.Subnet.get_object(context, id=id) subnet = subnet_obj or obj_subnet.Subnet.get_object(context, id=id)
old_segment_id = subnet.segment_id if subnet else None old_segment_id = subnet.segment_id if subnet else None
if 'segment_id' in s: if 'segment_id' in s:
self._validate_segment( self._validate_segment(
@ -506,7 +506,7 @@ class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
# so create unchanged copy for ipam driver # so create unchanged copy for ipam driver
subnet_copy = copy.deepcopy(s) subnet_copy = copy.deepcopy(s)
subnet, changes = super(IpamPluggableBackend, self).update_db_subnet( subnet, changes = super(IpamPluggableBackend, self).update_db_subnet(
context, id, s, old_pools) context, id, s, old_pools, subnet_obj=subnet_obj)
ipam_driver = driver.Pool.get_instance(None, context) ipam_driver = driver.Pool.get_instance(None, context)
# Set old allocation pools if no new pools are provided by user. # Set old allocation pools if no new pools are provided by user.