Fix race condition when creating two routers without HA network
When a HA router is created and the HA is not yet, before creating
the router, the Neutron server creates the HA network and the
corresponding subnet.
The HA network cannot be duplicated (see previous patches related to
this bug). But the subnet, that is created in another database
transaction, cannot be present when the router creation call tries
to create the HA port.
This patch adds a HA subnet check before creating the router and the
HA port. Even if the subnet check fails and the worker tries to
create this subnet, if the process fails with ``InvalidInput``, that
means other worker created the subnet before and the current one
fails because tries to create the same subnet with the same CIDR.
In this case, we dismiss the exception and continue with the router
creation.
Reviewed: https:/ /review. opendev. org/c/openstack /neutron/ +/881826 /opendev. org/openstack/ neutron/ commit/ e6fb32e27d1141c a4b00c3758ee44b fe2f060ccf
Committed: https:/
Submitter: "Zuul (22348)"
Branch: master
commit e6fb32e27d1141c a4b00c3758ee44b fe2f060ccf
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Fri Apr 28 13:56:02 2023 +0000
Fix race condition when creating two routers without HA network
When a HA router is created and the HA is not yet, before creating
the router, the Neutron server creates the HA network and the
corresponding subnet.
The HA network cannot be duplicated (see previous patches related to
this bug). But the subnet, that is created in another database
transaction, cannot be present when the router creation call tries
to create the HA port.
This patch adds a HA subnet check before creating the router and the
HA port. Even if the subnet check fails and the worker tries to
create this subnet, if the process fails with ``InvalidInput``, that
means other worker created the subnet before and the current one
fails because tries to create the same subnet with the same CIDR.
In this case, we dismiss the exception and continue with the router
creation.
Closes-Bug: #2016198
Change-Id: I82225fcc6248bb 0fd68959ceb1daa bff423d81ff