From ff145ff721b1047719c7cbafbea7a5fdf15c390d Mon Sep 17 00:00:00 2001 From: zhangzujian Date: Wed, 17 Aug 2022 14:37:17 +0800 Subject: [PATCH] fix duplicate log for tunnel interface decision --- pkg/daemon/config.go | 6 +++++- pkg/daemon/controller_linux.go | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/daemon/config.go b/pkg/daemon/config.go index ab6fd2902b3..57c35df91f4 100644 --- a/pkg/daemon/config.go +++ b/pkg/daemon/config.go @@ -28,6 +28,8 @@ import ( // Configuration is the daemon conf type Configuration struct { + // interface being used for tunnel + tunnelIface string Iface string DPDKTunnelIface string MTU int @@ -205,7 +207,10 @@ func (config *Configuration) initNicConfig(nicBridgeMappings map[string]string) if len(encapIP) == 0 { return fmt.Errorf("iface %s has no valid IP address", tunnelNic) } + + klog.Infof("use %s as tunnel interface", iface.Name) mtu = iface.MTU + config.tunnelIface = iface.Name } encapIsIPv6 := util.CheckProtocol(encapIP) == kubeovnv1.ProtocolIPv6 @@ -278,7 +283,6 @@ func findInterface(ifaceStr string) (*net.Interface, error) { } for _, iface := range ifaces { if ifaceRegex.MatchString(iface.Name) { - klog.Infof("use %s as tunnel interface", iface.Name) return &iface, nil } } diff --git a/pkg/daemon/controller_linux.go b/pkg/daemon/controller_linux.go index 90c81509968..93c6b998bd8 100644 --- a/pkg/daemon/controller_linux.go +++ b/pkg/daemon/controller_linux.go @@ -500,6 +500,10 @@ func (c *Controller) loopEncapIpCheck() { klog.Errorf("iface %s has no ip address", nodeTunnelName) return } + if iface.Name != c.config.tunnelIface { + klog.Infof("use %s as tunnel interface", iface.Name) + c.config.tunnelIface = iface.Name + } // if assigned iface in node annotation is down or with no ip, the error msg should be printed periodically if c.config.Iface == nodeTunnelName {