diff --git a/cmd/controller/controller.go b/cmd/controller/controller.go index c0ebf036110..e5845b87c50 100644 --- a/cmd/controller/controller.go +++ b/cmd/controller/controller.go @@ -26,7 +26,7 @@ func CmdMain() { defer klog.Flush() stopCh := signals.SetupSignalHandler() - klog.Infof(versions.String()) + klog.Info(versions.String()) controller.InitClientGoMetrics() controller.InitWorkQueueMetrics() diff --git a/cmd/daemon/cniserver.go b/cmd/daemon/cniserver.go index a9d4ae8b2e9..145ab22fd49 100644 --- a/cmd/daemon/cniserver.go +++ b/cmd/daemon/cniserver.go @@ -27,7 +27,7 @@ import ( func CmdMain() { defer klog.Flush() - klog.Infof(versions.String()) + klog.Info(versions.String()) daemon.InitMetrics() util.InitKlogMetrics() diff --git a/cmd/ovn_monitor/ovn_monitor.go b/cmd/ovn_monitor/ovn_monitor.go index 1682d7b34f6..68b32ed5f2c 100644 --- a/cmd/ovn_monitor/ovn_monitor.go +++ b/cmd/ovn_monitor/ovn_monitor.go @@ -19,7 +19,7 @@ import ( func CmdMain() { defer klog.Flush() - klog.Infof(versions.String()) + klog.Info(versions.String()) config, err := ovn.ParseFlags() if err != nil { util.LogFatalAndExit(err, "failed to parse config") diff --git a/cmd/pinger/pinger.go b/cmd/pinger/pinger.go index bd8ef68d998..ff1ee11f6a0 100644 --- a/cmd/pinger/pinger.go +++ b/cmd/pinger/pinger.go @@ -17,7 +17,7 @@ import ( func CmdMain() { defer klog.Flush() - klog.Infof(versions.String()) + klog.Info(versions.String()) pinger.InitPingerMetrics() util.InitKlogMetrics() config, err := pinger.ParseFlags() diff --git a/cmd/speaker/speaker.go b/cmd/speaker/speaker.go index d61cb9e5f31..0348ac7d11f 100644 --- a/cmd/speaker/speaker.go +++ b/cmd/speaker/speaker.go @@ -17,7 +17,7 @@ import ( func CmdMain() { defer klog.Flush() - klog.Infof(versions.String()) + klog.Info(versions.String()) config, err := speaker.ParseFlags() if err != nil { util.LogFatalAndExit(err, "failed to parse config") diff --git a/cmd/webhook/server.go b/cmd/webhook/server.go index b20cb9ff6ad..b8babf305bc 100644 --- a/cmd/webhook/server.go +++ b/cmd/webhook/server.go @@ -37,7 +37,7 @@ func init() { func main() { var port int - klog.Infof(versions.String()) + klog.Info(versions.String()) port = *pflag.Int("port", 8443, "The port webhook listen on.") diff --git a/pkg/controller/namespace.go b/pkg/controller/namespace.go index ed0225a8e6c..1388f4e1570 100644 --- a/pkg/controller/namespace.go +++ b/pkg/controller/namespace.go @@ -177,7 +177,7 @@ func (c *Controller) handleAddNamespace(key string) error { } op := "replace" - if namespace.Annotations == nil || len(namespace.Annotations) == 0 { + if len(namespace.Annotations) == 0 { op = "add" namespace.Annotations = map[string]string{} } else { diff --git a/pkg/daemon/ovs.go b/pkg/daemon/ovs.go index 1d4f9c1dc28..78225f8eb72 100644 --- a/pkg/daemon/ovs.go +++ b/pkg/daemon/ovs.go @@ -374,7 +374,7 @@ func configureNodeNic(portName, ip, gw, joinCIDR string, macAddr net.HardwareAdd fmt.Sprintf("external_ids:ip=%s", ipStr)) if err != nil { klog.Errorf("failed to configure node nic %s: %v, %q", portName, err, raw) - return fmt.Errorf(raw) + return errors.New(raw) } if err = configureNic(util.NodeNic, ip, macAddr, mtu, false, false); err != nil { @@ -484,7 +484,7 @@ func configureGlobalMirror(portName string, mtu int) error { "add", "bridge", "br-int", "mirrors", "@m") if err != nil { klog.Errorf("failed to configure mirror nic %s %q", portName, raw) - return fmt.Errorf(raw) + return errors.New(raw) } return configureMirrorLink(portName, mtu) } @@ -498,7 +498,7 @@ func configureEmptyMirror(portName string, mtu int) error { "add", "bridge", "br-int", "mirrors", "@m") if err != nil { klog.Errorf("failed to configure mirror nic %s %q", portName, raw) - return fmt.Errorf(raw) + return errors.New(raw) } return configureMirrorLink(portName, mtu) } diff --git a/pkg/daemon/server.go b/pkg/daemon/server.go index c5417d9914b..801e72f6399 100644 --- a/pkg/daemon/server.go +++ b/pkg/daemon/server.go @@ -64,7 +64,7 @@ func createHandler(csh *cniServerHandler) http.Handler { func requestAndResponseLogger(request *restful.Request, response *restful.Response, chain *restful.FilterChain, ) { - klog.Infof(formatRequestLog(request)) + klog.Info(formatRequestLog(request)) start := time.Now() chain.ProcessFilter(request, response) elapsed := float64((time.Since(start)) / time.Millisecond) @@ -72,7 +72,7 @@ func requestAndResponseLogger(request *restful.Request, response *restful.Respon nodeName, getRequestURI(request), fmt.Sprintf("%d", response.StatusCode())).Observe(elapsed / 1000) - klog.Infof(formatResponseLog(response, request, elapsed)) + klog.Info(formatResponseLog(response, request, elapsed)) } // formatRequestLog formats request log string. diff --git a/pkg/ovs/ovs-vsctl.go b/pkg/ovs/ovs-vsctl.go index e80279c1853..f49dfe102e2 100644 --- a/pkg/ovs/ovs-vsctl.go +++ b/pkg/ovs/ovs-vsctl.go @@ -327,7 +327,7 @@ func ConfigInterfaceMirror(globalMirror bool, open, iface string) error { return err } if len(portUUIDs) != 1 { - return fmt.Errorf(fmt.Sprintf("find port failed, portName=%s", ifName)) + return fmt.Errorf("find port failed, portName=%s", ifName) } portId := portUUIDs[0] if open == "true" { diff --git a/pkg/util/network_attachment.go b/pkg/util/network_attachment.go index dc62c53e6da..d868d4d64e7 100644 --- a/pkg/util/network_attachment.go +++ b/pkg/util/network_attachment.go @@ -47,12 +47,12 @@ func parsePodNetworkObjectName(podnetwork string) (string, string, string, error // nolint:staticcheck matched, _ := regexp.MatchString("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$", allItems[i]) if !matched && len([]rune(allItems[i])) > 0 { - klog.Errorf(fmt.Sprintf("parsePodNetworkObjectName: Failed to parse: "+ + klog.Errorf("parsePodNetworkObjectName: Failed to parse: "+ "one or more items did not match comma-delimited format (must consist of lower case alphanumeric characters). "+ - "Must start and end with an alphanumeric character), mismatch @ '%v'", allItems[i])) - return "", "", "", fmt.Errorf(fmt.Sprintf("parsePodNetworkObjectName: Failed to parse: "+ + "Must start and end with an alphanumeric character), mismatch @ '%v'", allItems[i]) + return "", "", "", fmt.Errorf("parsePodNetworkObjectName: Failed to parse: "+ "one or more items did not match comma-delimited format (must consist of lower case alphanumeric characters). "+ - "Must start and end with an alphanumeric character), mismatch @ '%v'", allItems[i])) + "Must start and end with an alphanumeric character), mismatch @ '%v'", allItems[i]) } }