Skip to content

Commit

Permalink
Enable cluster manager support for layer2 networks
Browse files Browse the repository at this point in the history
Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
  • Loading branch information
jcaamano committed Jun 27, 2023
1 parent 913c59a commit 5ac2f7c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 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
8 changes: 6 additions & 2 deletions go-controller/pkg/ovn/base_network_controller_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,13 @@ func (bnc *BaseNetworkController) WatchPods() error {

func (bnc *BaseNetworkController) handlesPodIPAllocation() bool {
// the controller is in charge of pod IP allocation except L2 topologies
// with IPAM on interconnect
// on interconnect
switch bnc.NetInfo.TopologyType() {
case ovntypes.Layer2Topology, ovntypes.LocalnetTopology:
case ovntypes.Layer2Topology:
// with interconnect, cluster manager allocates IPs and IDs
return !config.OVNKubernetesFeature.EnableInterconnect
case ovntypes.LocalnetTopology:
// with interconnect and IPAM, cluster manager allocates IPs
return !config.OVNKubernetesFeature.EnableInterconnect || !bnc.doesNetworkRequireIPAM()
}
return true
Expand Down

0 comments on commit 5ac2f7c

Please sign in to comment.