Skip to content

Commit b4b15ef

Browse files
committed
advertised network isolation: delete isolation entries with one trasaction
Signed-off-by: Patryk Diak <[email protected]>
1 parent bb0bdce commit b4b15ef

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

go-controller/pkg/ovn/udn_isolation.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ func (bnc *BaseNetworkController) addAdvertisedNetworkIsolation(nodeName string)
360360
return nil
361361
}
362362

363-
// deleteAdvertisedNetworkIsolation deletes advertised network isolation rules from the given node switch
363+
// deleteAdvertisedNetworkIsolation deletes advertised network isolation rules from the given node switch.
364+
// It removes the network CIDRs from the global advertised networks addresset together with the ACLs on the node switch.
364365
func (bnc *BaseNetworkController) deleteAdvertisedNetworkIsolation(nodeName string) error {
365366
addrSet, err := bnc.addressSetFactory.GetAddressSet(GetAdvertisedNetworkSubnetsAddressSetDBIDs())
366367
if err != nil {
@@ -371,9 +372,9 @@ func (bnc *BaseNetworkController) deleteAdvertisedNetworkIsolation(nodeName stri
371372
for _, subnet := range bnc.Subnets() {
372373
cidrs = append(cidrs, subnet.CIDR.String())
373374
}
374-
err = addrSet.DeleteAddresses(cidrs)
375+
ops, err := addrSet.DeleteAddressesReturnOps(cidrs)
375376
if err != nil {
376-
return err
377+
return fmt.Errorf("failed to create ovsdb ops for deleting the addresses from %s addresset for network %s: %w", GetAdvertisedNetworkSubnetsAddressSetDBIDs(), bnc.GetNetworkName(), err)
377378
}
378379

379380
passACLIDs := GetAdvertisedNetworkSubnetsPassACLdbIDs(bnc.controllerName, bnc.GetNetworkName(), bnc.GetNetworkID())
@@ -392,10 +393,11 @@ func (bnc *BaseNetworkController) deleteAdvertisedNetworkIsolation(nodeName stri
392393

393394
// ACLs referenced by the switch will be deleted by db if there are no other references
394395
p := func(sw *nbdb.LogicalSwitch) bool { return sw.Name == bnc.GetNetworkScopedSwitchName(nodeName) }
395-
err = libovsdbops.RemoveACLsFromLogicalSwitchesWithPredicate(bnc.nbClient, p, append(passACLs, dropACLs...)...)
396+
ops, err = libovsdbops.RemoveACLsFromLogicalSwitchesWithPredicateOps(bnc.nbClient, ops, p, append(passACLs, dropACLs...)...)
396397
if err != nil {
397-
return fmt.Errorf("failed to remove network isolation ACLs from the %s switch for network %s: %w", bnc.GetNetworkScopedSwitchName(nodeName), bnc.GetNetworkName(), err)
398+
return fmt.Errorf("failed to create ovsdb ops for removing network isolation ACLs from the %s switch for network %s: %w", bnc.GetNetworkScopedSwitchName(nodeName), bnc.GetNetworkName(), err)
398399
}
399400

400-
return nil
401+
_, err = libovsdbops.TransactAndCheck(bnc.nbClient, ops)
402+
return err
401403
}

0 commit comments

Comments
 (0)