From 2e69489cc69784ec37d6378dd7678a17dd139448 Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Sat, 29 Nov 2025 10:27:41 +0200 Subject: [PATCH] Update golangci-lint to v2.6.2 --- .github/workflows/lint.yml | 2 +- Makefile | 2 +- .../exporterplugins/stackdriver_exporter_plugin.go | 1 - cmd/nodeproblemdetector/node_problem_detector_test.go | 1 - .../node_problem_detector_windows_test.go | 1 - .../problemdaemonplugins/custom_plugin_monitor_plugin.go | 1 - .../problemdaemonplugins/system_log_monitor_plugin.go | 1 - .../problemdaemonplugins/system_stats_monitor_plugin.go | 1 - pkg/custompluginmonitor/plugin/plugin.go | 2 +- pkg/exporters/stackdriver/stackdriver_exporter_test.go | 1 - pkg/healthchecker/health_checker_darwin.go | 1 + pkg/systemlogmonitor/logwatchers/kmsg/log_watcher_darwin.go | 1 + pkg/systemlogmonitor/logwatchers/register_journald.go | 1 - pkg/util/exec_test.go | 4 +++- pkg/util/exec_unix.go | 5 +++-- pkg/util/exec_windows.go | 5 +++-- 16 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3993e834..ba920983 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,6 +9,6 @@ jobs: - name: Set up Go uses: actions/setup-go@v6 with: - go-version: 1.24 + go-version-file: go.mod - name: golangci-lint run: make lint diff --git a/Makefile b/Makefile index 714b6d9e..680ddb49 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,7 @@ else LOGCOUNTER=*dont-include-log-counter endif -GOLANGCI_LINT_VERSION := v2.2.0 +GOLANGCI_LINT_VERSION := v2.6.2 GOLANGCI_LINT := ./.bin/golangci-lint lint: $(GOLANGCI_LINT) diff --git a/cmd/nodeproblemdetector/exporterplugins/stackdriver_exporter_plugin.go b/cmd/nodeproblemdetector/exporterplugins/stackdriver_exporter_plugin.go index cfb72438..527743d4 100644 --- a/cmd/nodeproblemdetector/exporterplugins/stackdriver_exporter_plugin.go +++ b/cmd/nodeproblemdetector/exporterplugins/stackdriver_exporter_plugin.go @@ -1,5 +1,4 @@ //go:build !disable_stackdriver_exporter -// +build !disable_stackdriver_exporter /* Copyright 2019 The Kubernetes Authors All rights reserved. diff --git a/cmd/nodeproblemdetector/node_problem_detector_test.go b/cmd/nodeproblemdetector/node_problem_detector_test.go index 83dd320e..95eaa539 100644 --- a/cmd/nodeproblemdetector/node_problem_detector_test.go +++ b/cmd/nodeproblemdetector/node_problem_detector_test.go @@ -1,5 +1,4 @@ //go:build !disable_system_log_monitor -// +build !disable_system_log_monitor /* Copyright 2021 The Kubernetes Authors All rights reserved. diff --git a/cmd/nodeproblemdetector/node_problem_detector_windows_test.go b/cmd/nodeproblemdetector/node_problem_detector_windows_test.go index b1396654..445cdcb8 100644 --- a/cmd/nodeproblemdetector/node_problem_detector_windows_test.go +++ b/cmd/nodeproblemdetector/node_problem_detector_windows_test.go @@ -1,5 +1,4 @@ //go:build !disable_system_log_monitor -// +build !disable_system_log_monitor /* Copyright 2021 The Kubernetes Authors All rights reserved. diff --git a/cmd/nodeproblemdetector/problemdaemonplugins/custom_plugin_monitor_plugin.go b/cmd/nodeproblemdetector/problemdaemonplugins/custom_plugin_monitor_plugin.go index b3a3980b..06e02b04 100644 --- a/cmd/nodeproblemdetector/problemdaemonplugins/custom_plugin_monitor_plugin.go +++ b/cmd/nodeproblemdetector/problemdaemonplugins/custom_plugin_monitor_plugin.go @@ -1,5 +1,4 @@ //go:build !disable_custom_plugin_monitor -// +build !disable_custom_plugin_monitor /* Copyright 2019 The Kubernetes Authors All rights reserved. diff --git a/cmd/nodeproblemdetector/problemdaemonplugins/system_log_monitor_plugin.go b/cmd/nodeproblemdetector/problemdaemonplugins/system_log_monitor_plugin.go index 3b090a1f..e57a1fac 100644 --- a/cmd/nodeproblemdetector/problemdaemonplugins/system_log_monitor_plugin.go +++ b/cmd/nodeproblemdetector/problemdaemonplugins/system_log_monitor_plugin.go @@ -1,5 +1,4 @@ //go:build !disable_system_log_monitor -// +build !disable_system_log_monitor /* Copyright 2019 The Kubernetes Authors All rights reserved. diff --git a/cmd/nodeproblemdetector/problemdaemonplugins/system_stats_monitor_plugin.go b/cmd/nodeproblemdetector/problemdaemonplugins/system_stats_monitor_plugin.go index 7c57a917..d7980695 100644 --- a/cmd/nodeproblemdetector/problemdaemonplugins/system_stats_monitor_plugin.go +++ b/cmd/nodeproblemdetector/problemdaemonplugins/system_stats_monitor_plugin.go @@ -1,5 +1,4 @@ //go:build !disable_system_stats_monitor -// +build !disable_system_stats_monitor /* Copyright 2019 The Kubernetes Authors All rights reserved. diff --git a/pkg/custompluginmonitor/plugin/plugin.go b/pkg/custompluginmonitor/plugin/plugin.go index d3ec3e3e..f3668eb5 100644 --- a/pkg/custompluginmonitor/plugin/plugin.go +++ b/pkg/custompluginmonitor/plugin/plugin.go @@ -154,7 +154,7 @@ func (p *Plugin) run(rule cpmtypes.CustomRule) (exitStatus cpmtypes.Status, outp } defer cancel() - cmd := util.Exec(rule.Path, rule.Args...) + cmd := util.Exec(ctx, rule.Path, rule.Args...) stdoutPipe, err := cmd.StdoutPipe() if err != nil { diff --git a/pkg/exporters/stackdriver/stackdriver_exporter_test.go b/pkg/exporters/stackdriver/stackdriver_exporter_test.go index e179139b..c73ffee0 100644 --- a/pkg/exporters/stackdriver/stackdriver_exporter_test.go +++ b/pkg/exporters/stackdriver/stackdriver_exporter_test.go @@ -1,5 +1,4 @@ //go:build !disable_stackdriver_exporter -// +build !disable_stackdriver_exporter /* Copyright 2019 The Kubernetes Authors All rights reserved. diff --git a/pkg/healthchecker/health_checker_darwin.go b/pkg/healthchecker/health_checker_darwin.go index 19f87731..fd044c02 100644 --- a/pkg/healthchecker/health_checker_darwin.go +++ b/pkg/healthchecker/health_checker_darwin.go @@ -21,6 +21,7 @@ import ( "time" "k8s.io/klog/v2" + "k8s.io/node-problem-detector/cmd/healthchecker/options" ) diff --git a/pkg/systemlogmonitor/logwatchers/kmsg/log_watcher_darwin.go b/pkg/systemlogmonitor/logwatchers/kmsg/log_watcher_darwin.go index c7e121ac..58977d8a 100644 --- a/pkg/systemlogmonitor/logwatchers/kmsg/log_watcher_darwin.go +++ b/pkg/systemlogmonitor/logwatchers/kmsg/log_watcher_darwin.go @@ -20,6 +20,7 @@ import ( "runtime" "k8s.io/klog/v2" + "k8s.io/node-problem-detector/pkg/systemlogmonitor/logwatchers/types" ) diff --git a/pkg/systemlogmonitor/logwatchers/register_journald.go b/pkg/systemlogmonitor/logwatchers/register_journald.go index bc374fca..a98a5d47 100644 --- a/pkg/systemlogmonitor/logwatchers/register_journald.go +++ b/pkg/systemlogmonitor/logwatchers/register_journald.go @@ -1,5 +1,4 @@ //go:build journald -// +build journald /* Copyright 2016 The Kubernetes Authors All rights reserved. diff --git a/pkg/util/exec_test.go b/pkg/util/exec_test.go index f4578b84..1e6cf0e4 100644 --- a/pkg/util/exec_test.go +++ b/pkg/util/exec_test.go @@ -17,6 +17,7 @@ limitations under the License. package util import ( + "context" "fmt" "runtime" "testing" @@ -41,10 +42,11 @@ func TestExec(t *testing.T) { } } + ctx := context.TODO() for _, v := range cmds { args := v t.Run(fmt.Sprintf("%v", args), func(t *testing.T) { - cmd := Exec(args[0], args[1:]...) + cmd := Exec(ctx, args[0], args[1:]...) if err := Kill(cmd); err == nil { t.Error("Kill(cmd) expected to have error because of empty handle, got none") diff --git a/pkg/util/exec_unix.go b/pkg/util/exec_unix.go index d7311ba3..c58e6989 100644 --- a/pkg/util/exec_unix.go +++ b/pkg/util/exec_unix.go @@ -19,18 +19,19 @@ limitations under the License. package util import ( + "context" "fmt" "os/exec" "syscall" ) // Exec creates a new process with the specified arguments. -func Exec(name string, arg ...string) *exec.Cmd { +func Exec(ctx context.Context, name string, arg ...string) *exec.Cmd { // create a process group sysProcAttr := &syscall.SysProcAttr{ Setpgid: true, } - cmd := exec.Command(name, arg...) + cmd := exec.CommandContext(ctx, name, arg...) cmd.SysProcAttr = sysProcAttr return cmd } diff --git a/pkg/util/exec_windows.go b/pkg/util/exec_windows.go index 3e70d6f2..597e60d0 100644 --- a/pkg/util/exec_windows.go +++ b/pkg/util/exec_windows.go @@ -17,6 +17,7 @@ limitations under the License. package util import ( + "context" "fmt" "os" "os/exec" @@ -27,7 +28,7 @@ import ( ) // Exec creates a new process with the specified arguments. -func Exec(name string, arg ...string) *exec.Cmd { +func Exec(ctx context.Context, name string, arg ...string) *exec.Cmd { // Windows does not handle relative path names in exec very well. name = filepath.Clean(name) cmdArgs := arg @@ -48,7 +49,7 @@ func Exec(name string, arg ...string) *exec.Cmd { // Run directly. } - return exec.Command(name, cmdArgs...) + return exec.CommandContext(ctx, name, cmdArgs...) } // Powershell creates a new powershell process with the specified arguments