diff --git a/pkg/daemon/ovs.go b/pkg/daemon/ovs.go index 7af13f65461..7ba6e0a3462 100644 --- a/pkg/daemon/ovs.go +++ b/pkg/daemon/ovs.go @@ -61,6 +61,7 @@ func configureGlobalMirror(portName string, mtu int) error { } if !nicExist { + klog.Infof("nic %s not exist, create it", portName) raw, err := ovs.Exec(ovs.MayExist, "add-port", "br-int", portName, "--", "set", "interface", portName, "type=internal", "--", "clear", "bridge", "br-int", "mirrors", "--", @@ -68,17 +69,18 @@ func configureGlobalMirror(portName string, mtu int) error { "--id=@m", "create", "mirror", fmt.Sprintf("name=%s", util.MirrorDefaultName), "select_all=true", "output_port=@mirror0", "--", "add", "bridge", "br-int", "mirrors", "@m") if err != nil { - klog.Errorf("failed to configure mirror nic %s %q", portName, raw) + klog.Errorf("failed to configure mirror nic %s, %q, %v", portName, raw, err) return fmt.Errorf(raw) } } else { + klog.Infof("nic %s exist, configure it", portName) raw, err := ovs.Exec(ovs.MayExist, "add-port", "br-int", portName, "--", "clear", "bridge", "br-int", "mirrors", "--", "--id=@mirror0", "get", "port", portName, "--", "--id=@m", "create", "mirror", fmt.Sprintf("name=%s", util.MirrorDefaultName), "select_all=true", "output_port=@mirror0", "--", "add", "bridge", "br-int", "mirrors", "@m") if err != nil { - klog.Errorf("failed to configure mirror nic %s %q", portName, raw) + klog.Errorf("failed to configure mirror nic %s, %q, %v", portName, raw, err) return fmt.Errorf(raw) } } diff --git a/pkg/daemon/ovs_linux.go b/pkg/daemon/ovs_linux.go index 2b941f4d111..c4831ff91ae 100644 --- a/pkg/daemon/ovs_linux.go +++ b/pkg/daemon/ovs_linux.go @@ -917,11 +917,13 @@ func (c *Controller) patchNodeExternalGwLabel(key string, enabled bool) error { func configureMirrorLink(portName string, _ int) error { mirrorLink, err := netlink.LinkByName(portName) if err != nil { + klog.Error(err) return fmt.Errorf("can not find mirror nic %s: %v", portName, err) } if mirrorLink.Attrs().OperState != netlink.OperUp { if err = netlink.LinkSetUp(mirrorLink); err != nil { + klog.Error(err) return fmt.Errorf("can not set mirror nic %s up: %v", portName, err) } } @@ -932,10 +934,12 @@ func configureMirrorLink(portName string, _ int) error { func configureNic(link, ip string, macAddr net.HardwareAddr, mtu int, detectIPConflict bool) error { nodeLink, err := netlink.LinkByName(link) if err != nil { + klog.Error(err) return fmt.Errorf("can not find nic %s: %v", link, err) } if err = netlink.LinkSetHardwareAddr(nodeLink, macAddr); err != nil { + klog.Error(err) return fmt.Errorf("can not set mac address to nic %s: %v", link, err) } @@ -952,6 +956,7 @@ func configureNic(link, ip string, macAddr net.HardwareAddr, mtu int, detectIPCo if nodeLink.Attrs().OperState != netlink.OperUp { if err = netlink.LinkSetUp(nodeLink); err != nil { + klog.Error(err) return fmt.Errorf("can not set node nic %s up: %v", link, err) } } @@ -960,6 +965,7 @@ func configureNic(link, ip string, macAddr net.HardwareAddr, mtu int, detectIPCo ipAddMap := make(map[string]netlink.Addr) ipAddrs, err := netlink.AddrList(nodeLink, unix.AF_UNSPEC) if err != nil { + klog.Error(err) return fmt.Errorf("can not get addr %s: %v", nodeLink, err) } for _, ipAddr := range ipAddrs { @@ -987,6 +993,7 @@ func configureNic(link, ip string, macAddr net.HardwareAddr, mtu int, detectIPCo for ip, addr := range ipDelMap { klog.Infof("delete ip address %s on %s", ip, link) if err = netlink.AddrDel(nodeLink, &addr); err != nil { + klog.Error(err) return fmt.Errorf("delete address %s: %v", addr, err) } } @@ -1012,6 +1019,7 @@ func configureNic(link, ip string, macAddr net.HardwareAddr, mtu int, detectIPCo klog.Infof("add ip address %s to %s", ip, link) if err = netlink.AddrAdd(nodeLink, &addr); err != nil { + klog.Error(err) return fmt.Errorf("can not add address %v to nic %s: %v", addr, link, err) } }