Skip to content

Commit

Permalink
Enable cluster manager support for layer2 networks
Browse files Browse the repository at this point in the history
This will enable cluster manager to allocate the PodAnnotation to pods
on interconnect instead of the zone controllers.

Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
  • Loading branch information
jcaamano authored and trozet committed Jul 10, 2023
1 parent 213fa37 commit fb78549
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func (sncm *secondaryNetworkClusterManager) Stop() {
}

// NewNetworkController implements the networkAttachDefController.NetworkControllerManager
// interface function. This function is called by the net-attach-def controller when
// a layer2 or layer3 secondary network is created. Layer2 type is not handled here.
// interface function. This function is called by the net-attach-def controller when
// a secondary network is created.
func (sncm *secondaryNetworkClusterManager) NewNetworkController(nInfo util.NetInfo) (nad.NetworkController, error) {
if !sncm.isTopologyManaged(nInfo) {
return nil, nad.ErrNetworkControllerTopologyNotManaged
Expand All @@ -114,6 +114,8 @@ func (sncm *secondaryNetworkClusterManager) isTopologyManaged(nInfo util.NetInfo
switch nInfo.TopologyType() {
case ovntypes.Layer3Topology:
return true
case ovntypes.Layer2Topology:
return config.OVNKubernetesFeature.EnableInterconnect
case ovntypes.LocalnetTopology:
return config.OVNKubernetesFeature.EnableInterconnect && len(nInfo.Subnets()) > 0
}
Expand Down
12 changes: 12 additions & 0 deletions go-controller/pkg/clustermanager/secondary_network_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ var _ = ginkgo.Describe("Secondary Layer3 Cluster Controller Manager", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
config.Kubernetes.HostNetworkNamespace = ""

config.OVNKubernetesFeature.EnableMultiNetwork = true
config.OVNKubernetesFeature.EnableInterconnect = true
f, err = factory.NewClusterManagerWatchFactory(fakeClient)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
err = f.Start()
Expand All @@ -156,10 +158,20 @@ var _ = ginkgo.Describe("Secondary Layer3 Cluster Controller Manager", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
netInfo, err := util.NewNetInfo(&ovncnitypes.NetConf{NetConf: types.NetConf{Name: "blue"}, Topology: ovntypes.Layer2Topology})
gomega.Expect(err).NotTo(gomega.HaveOccurred())

config.OVNKubernetesFeature.EnableInterconnect = false
nc, err := sncm.NewNetworkController(netInfo)
gomega.Expect(err).To(gomega.Equal(nad.ErrNetworkControllerTopologyNotManaged))
gomega.Expect(nc).To(gomega.BeNil())

config.OVNKubernetesFeature.EnableInterconnect = true
nc, err = sncm.NewNetworkController(netInfo)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(nc).NotTo(gomega.BeNil())

err = nc.Start(ctx.Context)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

return nil
}

Expand Down

0 comments on commit fb78549

Please sign in to comment.