Skip to content

Commit ff971e2

Browse files
committed
Use NetInfo in management port
Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
1 parent 23e4eb2 commit ff971e2

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

go-controller/pkg/node/managementport/port.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"net"
55
"time"
66

7-
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util"
87
"k8s.io/apimachinery/pkg/util/wait"
98
"k8s.io/client-go/util/retry"
109
"k8s.io/klog/v2"
@@ -47,8 +46,6 @@ func (c *managementPortController) Start(stopChan <-chan struct{}) error {
4746
}
4847

4948
func (c *managementPortController) Reconcile() {
50-
advertised := util.IsPodNetworkAdvertisedAtNode(c.netInfo, c.nodeName)
51-
c.cfg.isPodNetworkAdvertised.Store(advertised)
5249
c.reconcile()
5350
}
5451

go-controller/pkg/node/managementport/port_config.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"net"
66
"strings"
7-
"sync/atomic"
87

98
corev1 "k8s.io/api/core/v1"
109
"k8s.io/klog/v2"
@@ -25,7 +24,7 @@ type managementPortConfig struct {
2524
ipv4 *managementPortIPFamilyConfig
2625
ipv6 *managementPortIPFamilyConfig
2726

28-
isPodNetworkAdvertised atomic.Bool
27+
netInfo util.NetInfo
2928
}
3029

3130
func newManagementPortConfig(node *corev1.Node, hostSubnets []*net.IPNet, netInfo util.NetInfo) (*managementPortConfig, error) {
@@ -57,11 +56,9 @@ func newManagementPortConfig(node *corev1.Node, hostSubnets []*net.IPNet, netInf
5756
nodeName: nodeName,
5857
hostSubnets: hostSubnets,
5958
mpMAC: mpMAC,
59+
netInfo: netInfo,
6060
}
6161

62-
advertised := util.IsPodNetworkAdvertisedAtNode(netInfo, node.Name)
63-
mpcfg.isPodNetworkAdvertised.Store(advertised)
64-
6562
for _, hostSubnet := range hostSubnets {
6663
isIPv6 := utilnet.IsIPv6CIDR(hostSubnet)
6764

go-controller/pkg/node/managementport/port_linux.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ type managementPortController struct {
4848
cfg *managementPortConfig
4949

5050
nodeName string
51-
netInfo util.NetInfo
5251

5352
reconcile func()
5453
}
@@ -371,7 +370,7 @@ func setupManagementPortNFTChain(interfaceName string, cfg *managementPortConfig
371370
),
372371
})
373372

374-
isPodNetworkAdvertised := cfg.isPodNetworkAdvertised.Load()
373+
isPodNetworkAdvertised := util.IsPodNetworkAdvertisedAtNode(cfg.netInfo, cfg.nodeName)
375374

376375
if cfg.ipv4 != nil {
377376
if isPodNetworkAdvertised {

go-controller/pkg/node/managementport/port_linux_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,15 +770,21 @@ var _ = Describe("Management Port tests", func() {
770770
It("removes stale nftables rules while keeping remaining intact", func() {
771771
nft := nodenft.SetFakeNFTablesHelper()
772772

773+
netInfo := &multinetworkmocks.NetInfo{}
774+
netInfo.On("GetPodNetworkAdvertisedOnNodeVRFs", "").Return(nil)
775+
773776
// Make a fake MgmtPortConfig with only the fields we care about
774777
nodeNet := ovntest.MustParseIPNet("10.1.1.0/24")
775778
fakeMgmtPortIPFamilyConfig := managementPortIPFamilyConfig{
776779
ifAddr: nodeNet,
777780
}
778781
fakeMgmtPortConfig := managementPortConfig{
779-
ipv4: &fakeMgmtPortIPFamilyConfig,
782+
ipv4: &fakeMgmtPortIPFamilyConfig,
783+
netInfo: netInfo,
780784
}
781-
err := setupManagementPortNFTChain(types.K8sMgmtIntfName, &fakeMgmtPortConfig)
785+
err := setupManagementPortNFTSets()
786+
Expect(err).NotTo(HaveOccurred())
787+
err = setupManagementPortNFTChain(types.K8sMgmtIntfName, &fakeMgmtPortConfig)
782788
Expect(err).NotTo(HaveOccurred())
783789

784790
finalExpectedNFT := nft.Dump()

0 commit comments

Comments
 (0)