Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian committed Jan 8, 2025
1 parent 6e5d7ae commit 2ea5fcd
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func CmdMain() {
defer klog.Flush()

stopCh := signals.SetupSignalHandler()
klog.Infof(versions.String())
klog.Info(versions.String())

controller.InitClientGoMetrics()
controller.InitWorkQueueMetrics()
Expand Down
2 changes: 1 addition & 1 deletion cmd/daemon/cniserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
func CmdMain() {
defer klog.Flush()

klog.Infof(versions.String())
klog.Info(versions.String())
daemon.InitMetrics()
util.InitKlogMetrics()

Expand Down
2 changes: 1 addition & 1 deletion cmd/ovn_monitor/ovn_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion cmd/pinger/pinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cmd/speaker/speaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion cmd/webhook/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/daemon/ovs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/daemon/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ 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)
cniOperationHistogram.WithLabelValues(
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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ovs/ovs-vsctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
8 changes: 4 additions & 4 deletions pkg/util/network_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
}

Expand Down

0 comments on commit 2ea5fcd

Please sign in to comment.