commit f913394d70dede8d40d6e96485bd5333dfb6f43f
Author: Mark Goddard <email address hidden>
Date: Fri Aug 30 16:58:34 2019 +0100
Create _mech_context before delete to avoid race
When a network is deleted, precommit handlers are notified prior to the
deletion of the network from the database. One handler exists in the ML2
plugin - _network_delete_precommit_handler. This handler queries the
database for the current state of the network and uses it to create a
NetworkContext which it saves under context._mech_context. When the
postcommit handler _network_delete_after_delete_handler is triggered
later, it passess the saved context._mech_context to mechanism drivers.
A problem can occur with provider networks since the segments service
also registers a precommit handler - _delete_segments_for_network. Both
precommit handlers use the default priority, so the order in which they
are called is random, and determined by dict ordering. If the segment
precommit handler executes first, it will delete the segments associated
with the network. When the ML2 plugin precommit handler runs it then
sees no segments for the network and sets the provider attributes of the
network in the NetworkContext to None.
A mechanism driver that is passed a NetworkContext without provider
attributes in its delete_network_postcommit method will not have the
information to perform the necessary actions. In the case of the
networking-generic-switch mechanism driver where this was observed, this
resulted in the driver ignoring the event, because the network did not
look like a VLAN.
This change uses a priority of zero for ML2 network delete precommit
handler, to ensure they query the network and store the NetworkContext
before the segments service has a chance to delete segments.
A similar change has been made for subnets, both to keep the pattern
consistent and avoid any similar issues.
Reviewed: https:/ /review. opendev. org/681663 /git.openstack. org/cgit/ openstack/ neutron/ commit/ ?id=f913394d70d ede8d40d6e96485 bd5333dfb6f43f
Committed: https:/
Submitter: Zuul
Branch: stable/rocky
commit f913394d70dede8 d40d6e96485bd53 33dfb6f43f
Author: Mark Goddard <email address hidden>
Date: Fri Aug 30 16:58:34 2019 +0100
Create _mech_context before delete to avoid race
When a network is deleted, precommit handlers are notified prior to the delete_ precommit_ handler. This handler queries the _mech_context. When the delete_ after_delete_ handler is triggered _mech_context to mechanism drivers.
deletion of the network from the database. One handler exists in the ML2
plugin - _network_
database for the current state of the network and uses it to create a
NetworkContext which it saves under context.
postcommit handler _network_
later, it passess the saved context.
A problem can occur with provider networks since the segments service segments_ for_network. Both
also registers a precommit handler - _delete_
precommit handlers use the default priority, so the order in which they
are called is random, and determined by dict ordering. If the segment
precommit handler executes first, it will delete the segments associated
with the network. When the ML2 plugin precommit handler runs it then
sees no segments for the network and sets the provider attributes of the
network in the NetworkContext to None.
A mechanism driver that is passed a NetworkContext without provider network_ postcommit method will not have the generic- switch mechanism driver where this was observed, this
attributes in its delete_
information to perform the necessary actions. In the case of the
networking-
resulted in the driver ignoring the event, because the network did not
look like a VLAN.
This change uses a priority of zero for ML2 network delete precommit
handler, to ensure they query the network and store the NetworkContext
before the segments service has a chance to delete segments.
A similar change has been made for subnets, both to keep the pattern
consistent and avoid any similar issues.
Change-Id: I6482223ed2a479 de4f5ef4cef056c 311c0281408 /review. opendev. org/680001 c88318121ed9a22 180e1ae96f)
Closes-Bug: #1841967
Depends-On: https:/
(cherry picked from commit fea2d9091f71a2e