I think it is because the current network deletion code doesn't follow the sequence as the network creation, the deletion should follow the reverse sequence(like the operations push and pop in a stack) to release related resources.
For example:
In the network creation function _create_network_db: it create network segment first, then mechanism_manager.create_network_precommit.
In the network deletion function delete_network: it send related deletion events of resources.NETWORK in the following order:
events.BEFORE_DELETE-> events.PRECOMMIT_DELETE -> events.AFTER_DELETE
when notified the event events.PRECOMMIT_DELETE, mechanism_manager.delete_network_precommit was triggered, however delete_segment was triggered either on the same event events.PRECOMMIT_DELETE(current implementation) or on the prior event events.BEFORE_DELETE (in the fix https://review.openstack.org/#/c/429441/8/neutron/services/segments/db.py ).
It is better to follow the push and pop operations to do the creation and deletion to avoid any potential resources dependence.
I think it is because the current network deletion code doesn't follow the sequence as the network creation, the deletion should follow the reverse sequence(like the operations push and pop in a stack) to release related resources.
For example: manager. create_ network_ precommit.
In the network creation function _create_network_db: it create network segment first, then mechanism_
In the network deletion function delete_network: it send related deletion events of resources.NETWORK in the following order: BEFORE_ DELETE- > events. PRECOMMIT_ DELETE -> events.AFTER_DELETE
events.
when notified the event events. PRECOMMIT_ DELETE, mechanism_ manager. delete_ network_ precommit was triggered, however delete_segment was triggered either on the same event events. PRECOMMIT_ DELETE( current implementation) or on the prior event events. BEFORE_ DELETE (in the fix https:/ /review. openstack. org/#/c/ 429441/ 8/neutron/ services/ segments/ db.py ).
It is better to follow the push and pop operations to do the creation and deletion to avoid any potential resources dependence.