Avoid race between withdraw_subnet and cr-lrp association

There is a chance that at the same time of processing a
withdraw_subnet event, its associated cr-lrp got moved to the
local chassis. This will lead to KeyError exception as the
withdraw process moves forward but the event to associate the
cr-lrp to the local chassis has not yet being processed.

In this case there is no need to process the withdraw_subnet
event in the local chassis as it has not yet been exposed. This
patch is adding protection for this case.

Change-Id: I64bd6e99cd6b38247b4a77c8a61860d51c6d116c
This commit is contained in:
Luis Tomas Bolivar 2023-02-10 10:51:17 +01:00
parent b9ebc55b57
commit a4c1fde816
1 changed files with 4 additions and 1 deletions

View File

@ -1005,7 +1005,10 @@ class OVNBGPDriver(driver_api.AgentDriverBase):
"triggering a subnet exposure.",
row.logical_port)
return
if not cr_lrp:
if not cr_lrp or cr_lrp not in self.ovn_local_cr_lrps.keys():
# NOTE(ltomasbo) there is a chance the cr-lrp just got moved
# to this node but was not yet processed. In that case there
# is no need to withdraw the network as it was not exposed here
return
self._withdraw_lrp_port(ip, row.logical_port, cr_lrp)