From 25473b58a96d66824db396207b51bcf549256579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=96=E5=BB=BA?= Date: Wed, 14 Aug 2024 21:39:55 +0800 Subject: [PATCH] ci: bump golangci-lint to v1.60.1 (#4407) Signed-off-by: zhangzujian --- .github/workflows/build-x86-image.yaml | 2 +- cmd/controller/controller.go | 2 +- cmd/daemon/cniserver.go | 2 +- cmd/ovn_ic_controller/ovn_ic_controller.go | 2 +- cmd/ovn_monitor/ovn_monitor.go | 2 +- cmd/pinger/pinger.go | 2 +- cmd/speaker/speaker.go | 2 +- cmd/webhook/server.go | 2 +- pkg/controller/namespace.go | 2 +- pkg/controller/service_lb.go | 2 +- pkg/controller/vpc_nat_gateway.go | 4 ++-- pkg/daemon/ovs_linux.go | 2 +- pkg/daemon/server.go | 4 ++-- pkg/speaker/config.go | 2 +- pkg/util/network_attachment.go | 4 ++-- test/e2e/iptables-vpc-nat-gw/e2e_test.go | 9 ++++----- 16 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build-x86-image.yaml b/.github/workflows/build-x86-image.yaml index 7033a36c484..1413026e5d6 100644 --- a/.github/workflows/build-x86-image.yaml +++ b/.github/workflows/build-x86-image.yaml @@ -23,7 +23,7 @@ concurrency: env: GO_VERSION: '' KIND_VERSION: v0.23.0 - GOLANGCI_LINT_VERSION: 'v1.59.1' + GOLANGCI_LINT_VERSION: 'v1.60.1' HELM_VERSION: v3.15.3 SUBMARINER_VERSION: '0.18.0' diff --git a/cmd/controller/controller.go b/cmd/controller/controller.go index 8849f550bd9..d8b4d49b855 100644 --- a/cmd/controller/controller.go +++ b/cmd/controller/controller.go @@ -35,7 +35,7 @@ const ovnLeaderResource = "kube-ovn-controller" func CmdMain() { defer klog.Flush() - klog.Infof(versions.String()) + klog.Info(versions.String()) currentCaps := cap.GetProc() klog.Infof("current capabilities: %s", currentCaps.String()) diff --git a/cmd/daemon/cniserver.go b/cmd/daemon/cniserver.go index f84389c5155..adb591ae0b1 100644 --- a/cmd/daemon/cniserver.go +++ b/cmd/daemon/cniserver.go @@ -33,7 +33,7 @@ func main() { metrics.InitKlogMetrics() config := daemon.ParseFlags() - klog.Infof(versions.String()) + klog.Info(versions.String()) if config.InstallCNIConfig { if err := mvCNIConf(config.CniConfDir, config.CniConfFile, config.CniConfName); err != nil { diff --git a/cmd/ovn_ic_controller/ovn_ic_controller.go b/cmd/ovn_ic_controller/ovn_ic_controller.go index 14e805b3d63..d1686f163b8 100644 --- a/cmd/ovn_ic_controller/ovn_ic_controller.go +++ b/cmd/ovn_ic_controller/ovn_ic_controller.go @@ -13,7 +13,7 @@ import ( func CmdMain() { defer klog.Flush() - klog.Infof(versions.String()) + klog.Info(versions.String()) currentCaps := cap.GetProc() klog.Infof("current capabilities: %s", currentCaps.String()) diff --git a/cmd/ovn_monitor/ovn_monitor.go b/cmd/ovn_monitor/ovn_monitor.go index 7a387d4a424..62bddddb564 100644 --- a/cmd/ovn_monitor/ovn_monitor.go +++ b/cmd/ovn_monitor/ovn_monitor.go @@ -20,7 +20,7 @@ const port = 10661 func CmdMain() { defer klog.Flush() - klog.Infof(versions.String()) + klog.Info(versions.String()) currentCaps := cap.GetProc() klog.Infof("current capabilities: %s", currentCaps.String()) diff --git a/cmd/pinger/pinger.go b/cmd/pinger/pinger.go index 0758b1e03db..1bb77d2a2a2 100644 --- a/cmd/pinger/pinger.go +++ b/cmd/pinger/pinger.go @@ -17,7 +17,7 @@ import ( func main() { defer klog.Flush() - klog.Infof(versions.String()) + klog.Info(versions.String()) currentCaps := cap.GetProc() klog.Infof("current capabilities: %s", currentCaps.String()) diff --git a/cmd/speaker/speaker.go b/cmd/speaker/speaker.go index 9ec674a1fc1..f9260c4795c 100644 --- a/cmd/speaker/speaker.go +++ b/cmd/speaker/speaker.go @@ -18,7 +18,7 @@ import ( func CmdMain() { defer klog.Flush() - klog.Infof(versions.String()) + klog.Info(versions.String()) currentCaps := cap.GetProc() klog.Infof("current capabilities: %s", currentCaps.String()) diff --git a/cmd/webhook/server.go b/cmd/webhook/server.go index 0c35b053993..6b6bb7ce227 100644 --- a/cmd/webhook/server.go +++ b/cmd/webhook/server.go @@ -37,7 +37,7 @@ func init() { } func CmdMain() { - klog.Infof(versions.String()) + klog.Info(versions.String()) port := pflag.Int("port", 8443, "The port webhook listen on.") healthProbePort := pflag.Int32("health-probe-port", 8080, "The port health probes listen on.") diff --git a/pkg/controller/namespace.go b/pkg/controller/namespace.go index ff02e6222bd..b875b555a28 100644 --- a/pkg/controller/namespace.go +++ b/pkg/controller/namespace.go @@ -194,7 +194,7 @@ func (c *Controller) handleAddNamespace(key string) error { excludeIps = append(excludeIps, strings.Join(subnet.Spec.ExcludeIps, ",")) } - if namespace.Annotations == nil || len(namespace.Annotations) == 0 { + if len(namespace.Annotations) == 0 { namespace.Annotations = map[string]string{} } else if namespace.Annotations[util.LogicalSwitchAnnotation] == strings.Join(lss, ",") && namespace.Annotations[util.CidrAnnotation] == strings.Join(cidrs, ";") && diff --git a/pkg/controller/service_lb.go b/pkg/controller/service_lb.go index cd3bc756bb5..420c010ed2d 100644 --- a/pkg/controller/service_lb.go +++ b/pkg/controller/service_lb.go @@ -260,7 +260,7 @@ func (c *Controller) deleteLbSvc(svc *corev1.Service) error { func (c *Controller) execNatRules(pod *corev1.Pod, operation string, rules []string) error { cmd := fmt.Sprintf("bash /kube-ovn/lb-svc.sh %s %s", operation, strings.Join(rules, " ")) - klog.V(3).Infof(cmd) + klog.V(3).Info(cmd) stdOutput, errOutput, err := util.ExecuteCommandInContainer(c.config.KubeClient, c.config.KubeRestConfig, pod.Namespace, pod.Name, "lb-svc", []string{"/bin/bash", "-c", cmd}...) if err != nil { if len(errOutput) > 0 { diff --git a/pkg/controller/vpc_nat_gateway.go b/pkg/controller/vpc_nat_gateway.go index 6e772485fd5..78e82666223 100644 --- a/pkg/controller/vpc_nat_gateway.go +++ b/pkg/controller/vpc_nat_gateway.go @@ -567,7 +567,7 @@ func (c *Controller) handleUpdateVpcDnat(natGwKey string) error { func (c *Controller) getIptablesVersion(pod *corev1.Pod) (version string, err error) { operation := getIptablesVersion cmd := fmt.Sprintf("bash /kube-ovn/nat-gateway.sh %s", operation) - klog.V(3).Infof(cmd) + klog.V(3).Info(cmd) stdOutput, errOutput, err := util.ExecuteCommandInContainer(c.config.KubeClient, c.config.KubeRestConfig, pod.Namespace, pod.Name, "vpc-nat-gw", []string{"/bin/bash", "-c", cmd}...) if err != nil { if len(errOutput) > 0 { @@ -712,7 +712,7 @@ func (c *Controller) handleUpdateNatGwSubnetRoute(natGwKey string) error { func (c *Controller) execNatGwRules(pod *corev1.Pod, operation string, rules []string) error { cmd := fmt.Sprintf("bash /kube-ovn/nat-gateway.sh %s %s", operation, strings.Join(rules, " ")) - klog.V(3).Infof(cmd) + klog.V(3).Info(cmd) stdOutput, errOutput, err := util.ExecuteCommandInContainer(c.config.KubeClient, c.config.KubeRestConfig, pod.Namespace, pod.Name, "vpc-nat-gw", []string{"/bin/bash", "-c", cmd}...) if err != nil { if len(errOutput) > 0 { diff --git a/pkg/daemon/ovs_linux.go b/pkg/daemon/ovs_linux.go index 41b69bff0a1..3bc89172857 100644 --- a/pkg/daemon/ovs_linux.go +++ b/pkg/daemon/ovs_linux.go @@ -262,7 +262,7 @@ func (csh cniServerHandler) releaseVf(podName, podNamespace, podNetns, ifName, n return nil }) if err != nil { - klog.Errorf(err.Error()) + klog.Error(err) } return nil diff --git a/pkg/daemon/server.go b/pkg/daemon/server.go index 01045d9ec68..14b95b6093b 100644 --- a/pkg/daemon/server.go +++ b/pkg/daemon/server.go @@ -63,7 +63,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) @@ -71,7 +71,7 @@ func requestAndResponseLogger(request *restful.Request, response *restful.Respon nodeName, getRequestURI(request), strconv.Itoa(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/speaker/config.go b/pkg/speaker/config.go index 49d2f69c58f..0bcd9bb20cc 100644 --- a/pkg/speaker/config.go +++ b/pkg/speaker/config.go @@ -113,7 +113,7 @@ func ParseFlags() (*Configuration, error) { if *argRouterID != "" && net.ParseIP(*argRouterID) == nil { return nil, fmt.Errorf("invalid router-id format: %s", *argRouterID) } - if *argEbgpMultihopTTL < 1 || *argEbgpMultihopTTL > 255 { + if *argEbgpMultihopTTL == 0 { return nil, errors.New("the bgp MultihopTtl must be in the range 1 to 255") } diff --git a/pkg/util/network_attachment.go b/pkg/util/network_attachment.go index 7c352222b56..2f123a8faac 100644 --- a/pkg/util/network_attachment.go +++ b/pkg/util/network_attachment.go @@ -28,7 +28,7 @@ func parsePodNetworkObjectName(podNetwork string) (string, string, string, error case 1: networkName = slashItems[0] default: - klog.Errorf("parsePodNetworkObjectName: Invalid network object (failed at '/')") + klog.Error("parsePodNetworkObjectName: Invalid network object (failed at '/')") return "", "", "", errors.New("parsePodNetworkObjectName: Invalid network object (failed at '/')") } @@ -49,7 +49,7 @@ func parsePodNetworkObjectName(podNetwork string) (string, string, string, error allItems := []string{netNsName, networkName, netIfName} for i := range allItems { if !attachmentRegexp.MatchString(allItems[i]) && len([]rune(allItems[i])) > 0 { - klog.Errorf(fmt.Sprintf("parsePodNetworkObjectName: Failed to parse: "+ + klog.Error(fmt.Sprintf("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("parsePodNetworkObjectName: Failed to parse: "+ diff --git a/test/e2e/iptables-vpc-nat-gw/e2e_test.go b/test/e2e/iptables-vpc-nat-gw/e2e_test.go index c9d382f7441..3bb50c6406b 100644 --- a/test/e2e/iptables-vpc-nat-gw/e2e_test.go +++ b/test/e2e/iptables-vpc-nat-gw/e2e_test.go @@ -1069,20 +1069,19 @@ func createNatGwAndSetQosCases(f *framework.Framework, } func validRateLimit(text string, limit int) bool { + maxValue := float64(limit) * 1024 * 1024 * 1.2 + minValue := float64(limit) * 1024 * 1024 * 0.8 lines := strings.Split(text, "\n") for _, line := range lines { if line == "" { continue } fields := strings.Split(line, ",") - lastField := fields[len(fields)-1] - number, err := strconv.Atoi(lastField) + number, err := strconv.Atoi(fields[len(fields)-1]) if err != nil { continue } - max := float64(limit) * 1024 * 1024 * 1.2 - min := float64(limit) * 1024 * 1024 * 0.8 - if min <= float64(number) && float64(number) <= max { + if v := float64(number); v >= minValue && v <= maxValue { return true } }