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
)
This commit is contained in:
parent
408c63af97
commit
1c55dbe825
|
@ -1074,7 +1074,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||||
need_network_update_notify = False
|
need_network_update_notify = False
|
||||||
|
|
||||||
with db_api.CONTEXT_WRITER.using(context):
|
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(
|
self._update_provider_network_attributes(
|
||||||
context, original_network, net_data)
|
context, original_network, net_data)
|
||||||
|
|
||||||
|
@ -1085,12 +1086,6 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||||
updated_network)
|
updated_network)
|
||||||
self._process_l3_update(context, updated_network, net_data)
|
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
|
if (mtuw_apidef.MTU in net_data or
|
||||||
# NOTE(ihrachys) mtu may be null for existing networks,
|
# NOTE(ihrachys) mtu may be null for existing networks,
|
||||||
# calculate and update it as needed; the conditional can be
|
# calculate and update it as needed; the conditional can be
|
||||||
|
@ -1137,11 +1132,11 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||||
return updated_network
|
return updated_network
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@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
|
# NOTE(ihrachys) use writer manager to be able to update mtu
|
||||||
# TODO(ihrachys) remove in Queens+ when mtu is not nullable
|
# TODO(ihrachys) remove in Queens+ when mtu is not nullable
|
||||||
with db_api.CONTEXT_WRITER.using(context):
|
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
|
# NOTE(ihrachys) pre Pike networks may have null mtus; update them
|
||||||
# in database if needed
|
# in database if needed
|
||||||
|
|
Loading…
Reference in New Issue