Skip to content

Commit

Permalink
Fix race between NAD and NetPol deletions
Browse files Browse the repository at this point in the history
It's noticed NAD is deleted even before handling NetPol delete event
which causes NetPol deletion never happened and error is always thrown
upon retries. This skips such primary network error and proceeds with
deleting netpol object.

Signed-off-by: Periyasamy Palanisamy <[email protected]>
  • Loading branch information
pperiyasamy authored and kyrtapz committed Jan 22, 2025
1 parent a99ad93 commit 13e1865
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions go-controller/pkg/ovn/base_network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,10 +1005,13 @@ func (bnc *BaseNetworkController) DeleteResourceCommon(objType reflect.Type, obj
return fmt.Errorf("could not cast obj of type %T to *knet.NetworkPolicy", obj)
}
netinfo, err := bnc.networkManager.GetActiveNetworkForNamespace(knp.Namespace)
if err != nil {
// The InvalidPrimaryNetworkError error is thrown when UDN is not found because
// it has been already deleted, so just proceed with deleting NetworkPolicy in
// such a scenario as well.
if err != nil && !errors.Is(err, util.NewInvalidPrimaryNetworkError(knp.Namespace)) {
return fmt.Errorf("could not get active network for namespace %s: %v", knp.Namespace, err)
}
if bnc.GetNetworkName() != netinfo.GetNetworkName() {
if err == nil && bnc.GetNetworkName() != netinfo.GetNetworkName() {
return nil
}
return bnc.deleteNetworkPolicy(knp)
Expand Down

0 comments on commit 13e1865

Please sign in to comment.