Skip to content

Commit 6379a5f

Browse files
committed
advertised network isolation: improve error wrapping
Signed-off-by: Patryk Diak <[email protected]>
1 parent c330e4c commit 6379a5f

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

go-controller/pkg/controllermanager/controller_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (cm *ControllerManager) CleanupStaleNetworks(validNetworks ...util.NetInfo)
201201
addressSetFactory := addressset.NewOvnAddressSetFactory(cm.nbClient, config.IPv4Mode, config.IPv6Mode)
202202
advertisedSubnets, err := addressSetFactory.GetAddressSet(ovn.GetAdvertisedUDNSubnetsAddressSetDBIDs())
203203
if err != nil {
204-
return err
204+
return fmt.Errorf("failed to get advertised subnets addresset %s: %w", ovn.GetAdvertisedUDNSubnetsAddressSetDBIDs(), err)
205205
}
206206
v4AdvertisedSubnets, v6AdvertisedSubnets := advertisedSubnets.GetAddresses()
207207
var invalidSubnets []string

go-controller/pkg/ovn/base_network_controller.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ func (bnc *BaseNetworkController) addAdvertisedUDNIsolation(nodeName string) err
12371237

12381238
addrSet, err := bnc.addressSetFactory.GetAddressSet(GetAdvertisedUDNSubnetsAddressSetDBIDs())
12391239
if err != nil {
1240-
return err
1240+
return fmt.Errorf("failed to get advertised subnets addresset %s for network %s: %w", GetAdvertisedUDNSubnetsAddressSetDBIDs(), bnc.GetNetworkName(), err)
12411241
}
12421242

12431243
for _, subnet := range bnc.Subnets() {
@@ -1252,7 +1252,7 @@ func (bnc *BaseNetworkController) addAdvertisedUDNIsolation(nodeName string) err
12521252

12531253
addrOps, err := addrSet.AddAddressesReturnOps(cidrs)
12541254
if err != nil {
1255-
return fmt.Errorf("failed to add addresses %q to the address set: %w", cidrs, err)
1255+
return fmt.Errorf("failed to add addresses %q to the %s address set for network %s: %w", cidrs, GetAdvertisedUDNSubnetsAddressSetDBIDs(), bnc.GetNetworkName(), err)
12561256
}
12571257
ops = append(ops, addrOps...)
12581258

@@ -1268,11 +1268,11 @@ func (bnc *BaseNetworkController) addAdvertisedUDNIsolation(nodeName string) err
12681268

12691269
ops, err = libovsdbops.CreateOrUpdateACLsOps(bnc.nbClient, ops, nil, acceptACL)
12701270
if err != nil {
1271-
return fmt.Errorf("failed to create or update udn isolation accept ACL %w", err)
1271+
return fmt.Errorf("failed to create or update udn isolation accept ACL %s for network %s: %w", GetAdvertisedUDNSubnetsAcceptACLdbIDs(bnc.GetNetworkName()), bnc.GetNetworkName(), err)
12721272
}
12731273
ops, err = libovsdbops.AddACLsToLogicalSwitchOps(bnc.nbClient, ops, bnc.GetNetworkScopedSwitchName(nodeName), acceptACL)
12741274
if err != nil {
1275-
return fmt.Errorf("failed to add udn isolation accept ACL to switch %s: %w", bnc.GetNetworkScopedSwitchName(nodeName), err)
1275+
return fmt.Errorf("failed to add udn isolation accept ACL to switch %s for network %s: %w", bnc.GetNetworkScopedSwitchName(nodeName), bnc.GetNetworkName(), err)
12761276
}
12771277
}
12781278

@@ -1283,17 +1283,19 @@ func (bnc *BaseNetworkController) addAdvertisedUDNIsolation(nodeName string) err
12831283
}
12841284
ops, err = libovsdbops.AddACLsToLogicalSwitchOps(bnc.nbClient, ops, bnc.GetNetworkScopedSwitchName(nodeName), dropACL)
12851285
if err != nil {
1286-
return fmt.Errorf("failed to add udn isolation drop ACL to switch %s: %w", bnc.GetNetworkScopedSwitchName(nodeName), err)
1286+
return fmt.Errorf("failed to add udn isolation drop ACL to switch %s for network %s: %w", bnc.GetNetworkScopedSwitchName(nodeName), bnc.GetNetworkName(), err)
12871287
}
12881288

1289-
_, err = libovsdbops.TransactAndCheck(bnc.nbClient, ops)
1290-
return err
1289+
if _, err = libovsdbops.TransactAndCheck(bnc.nbClient, ops); err != nil {
1290+
return fmt.Errorf("failed to configure udn isolation OVN rules for network %s: %w", bnc.GetNetworkName(), err)
1291+
}
1292+
return nil
12911293
}
12921294

12931295
func (bnc *BaseNetworkController) deleteAdvertisedUDNIsolation(nodeName string) error {
12941296
addrSet, err := bnc.addressSetFactory.GetAddressSet(GetAdvertisedUDNSubnetsAddressSetDBIDs())
12951297
if err != nil {
1296-
return err
1298+
return fmt.Errorf("failed to get advertised subnets addresset %s for network %s: %w", GetAdvertisedUDNSubnetsAddressSetDBIDs(), bnc.GetNetworkName(), err)
12971299
}
12981300

12991301
var cidrs []string
@@ -1309,21 +1311,21 @@ func (bnc *BaseNetworkController) deleteAdvertisedUDNIsolation(nodeName string)
13091311
acceptACLPredicate := libovsdbops.GetPredicate[*nbdb.ACL](acceptACLIDs, nil)
13101312
acceptACLs, err := libovsdbops.FindACLsWithPredicate(bnc.nbClient, acceptACLPredicate)
13111313
if err != nil {
1312-
return fmt.Errorf("unable to find the allow ACL for advertised UDN network: %v", err)
1314+
return fmt.Errorf("unable to find the allow ACL for advertised UDN network %s: %w", bnc.GetNetworkName(), err)
13131315
}
13141316

13151317
dropACLIDs := GetAdvertisedUDNSubnetsDropACLdbIDs()
13161318
dropACLPredicate := libovsdbops.GetPredicate[*nbdb.ACL](dropACLIDs, nil)
13171319
dropACLs, err := libovsdbops.FindACLsWithPredicate(bnc.nbClient, dropACLPredicate)
13181320
if err != nil {
1319-
return fmt.Errorf("unable to find the drop ACL for advertised UDN networks: %v", err)
1321+
return fmt.Errorf("unable to find the drop ACL for advertised UDN network %s: %w", bnc.GetNetworkName(), err)
13201322
}
13211323

13221324
// ACLs referenced by the switch will be deleted by db if there are no other references
13231325
p := func(sw *nbdb.LogicalSwitch) bool { return sw.Name == bnc.GetNetworkScopedSwitchName(nodeName) }
13241326
err = libovsdbops.RemoveACLsFromLogicalSwitchesWithPredicate(bnc.nbClient, p, append(acceptACLs, dropACLs...)...)
13251327
if err != nil {
1326-
return err
1328+
return fmt.Errorf("failed to remove network isolation ACLs from the %s switch for network %s: %w", bnc.GetNetworkScopedSwitchName(nodeName), bnc.GetNetworkName(), err)
13271329
}
13281330

13291331
return nil

0 commit comments

Comments
 (0)