Merge "Remove unneeded DB register retrieval and refresh in network update" into stable/stein

This commit is contained in:
Zuul 2021-06-01 16:56:30 +00:00 committed by Gerrit Code Review
commit fb93eb9495
1 changed files with 4 additions and 9 deletions

View File

@ -1032,7 +1032,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
need_network_update_notify = False
with db_api.CONTEXT_WRITER.using(context):
original_network = self.get_network(context, id)
db_network = self._get_network(context, id)
original_network = self.get_network(context, id, net_db=db_network)
self._update_provider_network_attributes(
context, original_network, net_data)
updated_network = super(Ml2Plugin, self).update_network(context,
@ -1042,12 +1043,6 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
updated_network)
self._process_l3_update(context, updated_network, net_data)
# ToDO(QoS): This would change once EngineFacade moves out
db_network = self._get_network(context, id)
# Expire the db_network in current transaction, so that the join
# relationship can be updated.
context.session.expire(db_network)
if (mtuw_apidef.MTU in net_data or
# NOTE(ihrachys) mtu may be null for existing networks,
# calculate and update it as needed; the conditional can be
@ -1094,11 +1089,11 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
return updated_network
@db_api.retry_if_session_inactive()
def get_network(self, context, id, fields=None):
def get_network(self, context, id, fields=None, net_db=None):
# NOTE(ihrachys) use writer manager to be able to update mtu
# TODO(ihrachys) remove in Queens+ when mtu is not nullable
with db_api.CONTEXT_WRITER.using(context):
net_db = self._get_network(context, id)
net_db = net_db or self._get_network(context, id)
# NOTE(ihrachys) pre Pike networks may have null mtus; update them
# in database if needed