Browse Source

Remove unneeded DB register retrieval and refresh in network update

The first DB operation done during a network update is a network DB
register retrieval. This information is stored in memory during
the DB transaction context and it's updated with any change done
to the DB register and the relationships; e.g., the network DB model
field "qos_policy_binding" is a backref relationship with a
"qos_network_policy_bindings" DB register. When a
"qos_network_policy_bindings" register is created, updated or
deleted, the network DB object, holding the relationship, will be
updated too.

There is no need therefore to retrieve again the DB object and
force a session update. The DB object contains the updated
information.

Trivial-Fix

Conflicts:
      neutron/plugins/ml2/plugin.py

Change-Id: I0c10b824c0f919607bb6ea31c5533ce7bd65df42
(cherry picked from commit 0e8ebf133d)
(cherry picked from commit 1c55dbe825)
changes/69/790169/1
Rodolfo Alonso Hernandez 1 year ago
committed by Vlad Gusev
parent
commit
42c099dd97
  1. 13
      neutron/plugins/ml2/plugin.py

13
neutron/plugins/ml2/plugin.py

@ -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

Loading…
Cancel
Save