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 committed Jul 11, 2023
1 parent cc35605 commit 6c3d49b
Show file tree
Hide file tree
Showing 2 changed files with 21 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 @@ -113,8 +113,15 @@ func (sncm *secondaryNetworkClusterManager) NewNetworkController(nInfo util.NetI
func (sncm *secondaryNetworkClusterManager) isTopologyManaged(nInfo util.NetInfo) bool {
switch nInfo.TopologyType() {
case ovntypes.Layer3Topology:
// we need to allocate subnets to each node regardless of configuration
return true
case ovntypes.Layer2Topology:
// for IC, both pod IPs and tunnel IDs need to be allocated
// in non IC config, this is done from ovnkube-master network controller

Check failure on line 120 in go-controller/pkg/clustermanager/secondary_network_cluster_manager.go

View workflow job for this annotation

GitHub Actions / Lint

File is not `gofmt`-ed with `-s` (gofmt)
return config.OVNKubernetesFeature.EnableInterconnect
case ovntypes.LocalnetTopology:
// for IC, pod IPs need to be allocated
// in non IC config, this is done from ovnkube-master network controller
return config.OVNKubernetesFeature.EnableInterconnect && len(nInfo.Subnets()) > 0
}
return false
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 6c3d49b

Please sign in to comment.