Skip to content

Commit

Permalink
Merge pull request ovn-org#3694 from jordigilh/fix/add_controller_nam…
Browse files Browse the repository at this point in the history
…e_apb_tests

Fix libovsdbops panic when testing apb external controller due to empty controllerName value
  • Loading branch information
trozet committed Jun 22, 2023
2 parents 89ef49b + ee6a035 commit fd9088f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ func initController(k8sObjects, routePolicyObjects []runtime.Object) {
iFactory, err = factory.NewMasterWatchFactory(&util.OVNMasterClientset{KubeClient: fakeClient})
Expect(err).NotTo(HaveOccurred())
iFactory.Start()
externalController, err = NewExternalMasterController(controllerName, fakeClient,
externalController, err = NewExternalMasterController(fakeClient,
fakeRouteClient,
stopChan,
iFactory.PodCoreInformer(),
iFactory.NamespaceInformer(),
iFactory.NodeCoreInformer().Lister(),
nbClient,
addressset.NewFakeAddressSetFactory(controllerName))
addressset.NewFakeAddressSetFactory(apbControllerName))
Expect(err).NotTo(HaveOccurred())
mgr = externalController.mgr
go func() {
Expand Down
12 changes: 4 additions & 8 deletions go-controller/pkg/ovn/controller/apbroute/master_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ import (
)

const (
resyncInterval = 0
maxRetries = 15
)

var (
controllerName string
resyncInterval = 0
maxRetries = 15
apbControllerName = "apb-external-route-controller"
)

// Admin Policy Based Route services
Expand Down Expand Up @@ -78,7 +75,6 @@ type ExternalGatewayMasterController struct {
}

func NewExternalMasterController(
parentControllerName string,
client kubernetes.Interface,
apbRoutePolicyClient adminpolicybasedrouteclient.Interface,
stopCh <-chan struct{},
Expand All @@ -89,7 +85,6 @@ func NewExternalMasterController(
addressSetFactory addressset.AddressSetFactory,
) (*ExternalGatewayMasterController, error) {

controllerName = parentControllerName
routePolicyInformer := adminpolicybasedrouteinformer.NewSharedInformerFactory(apbRoutePolicyClient, resyncInterval)
externalRouteInformer := routePolicyInformer.K8s().V1().AdminPolicyBasedExternalRoutes()
externalGWCache := make(map[ktypes.NamespacedName]*ExternalRouteInfo)
Expand All @@ -101,6 +96,7 @@ func NewExternalMasterController(
addressSetFactory: addressSetFactory,
externalGWCache: externalGWCache,
exGWCacheMutex: exGWCacheMutex,
controllerName: apbControllerName,
}

c := &ExternalGatewayMasterController{
Expand Down
7 changes: 4 additions & 3 deletions go-controller/pkg/ovn/controller/apbroute/network_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type northBoundClient struct {
addressSetFactory addressset.AddressSetFactory
externalGWCache map[ktypes.NamespacedName]*ExternalRouteInfo
exGWCacheMutex *sync.RWMutex
controllerName string
}

type conntrackClient struct {
Expand Down Expand Up @@ -76,7 +77,7 @@ func (nb *northBoundClient) delAllHybridRoutePolicies() error {

// nuke all the address-sets.
// if we fail to remove LRP's above, we don't attempt to remove ASes due to dependency constraints.
predicateIDs := libovsdbops.NewDbObjectIDs(libovsdbops.AddressSetHybridNodeRoute, controllerName, nil)
predicateIDs := libovsdbops.NewDbObjectIDs(libovsdbops.AddressSetHybridNodeRoute, nb.controllerName, nil)
asPred := libovsdbops.GetPredicate[*nbdb.AddressSet](predicateIDs, nil)
err = libovsdbops.DeleteAddressSetsWithPredicate(nb.nbClient, asPred)
if err != nil {
Expand Down Expand Up @@ -261,7 +262,7 @@ func (nb *northBoundClient) addGWRoutesForPod(gateways []*gatewayInfo, podIfAddr
func (nb *northBoundClient) addHybridRoutePolicyForPod(podIP net.IP, node string) error {
if config.Gateway.Mode == config.GatewayModeLocal {
// Add podIP to the node's address_set.
asIndex := getHybridRouteAddrSetDbIDs(node, controllerName)
asIndex := getHybridRouteAddrSetDbIDs(node, nb.controllerName)
as, err := nb.addressSetFactory.EnsureAddressSet(asIndex)
if err != nil {
return fmt.Errorf("cannot ensure that addressSet for node %s exists %v", node, err)
Expand Down Expand Up @@ -534,7 +535,7 @@ func (nb *northBoundClient) deleteLogicalRouterStaticRoute(podIP, mask, gw, gr s
func (nb *northBoundClient) delHybridRoutePolicyForPod(podIP net.IP, node string) error {
if config.Gateway.Mode == config.GatewayModeLocal {
// Delete podIP from the node's address_set.
asIndex := getHybridRouteAddrSetDbIDs(node, controllerName)
asIndex := getHybridRouteAddrSetDbIDs(node, nb.controllerName)
as, err := nb.addressSetFactory.EnsureAddressSet(asIndex)
if err != nil {
return fmt.Errorf("cannot Ensure that addressSet for node %s exists %v", node, err)
Expand Down
1 change: 0 additions & 1 deletion go-controller/pkg/ovn/default_network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ func newDefaultNetworkControllerCommon(cnci *CommonNetworkControllerInfo,
zoneChassisHandler = zoneic.NewZoneChassisHandler(cnci.sbClient)
}
apbExternalRouteController, err := apbroutecontroller.NewExternalMasterController(
DefaultNetworkControllerName,
cnci.client,
cnci.kube.APBRouteClient,
defaultStopChan,
Expand Down

0 comments on commit fd9088f

Please sign in to comment.