From b3e972141fbf068f66786b1a49026f86e74df859 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 24 Aug 2023 17:19:03 -0700 Subject: [PATCH 1/3] Add issue reference to nolint annotation Usually errorlint allows io.EOF comparison (based on a whitelist of functions that can return bare io.EOF), thus there is no need for nolint annotation. In this very case, though, the need for nolint is caused by issue with errorlint, which fails to see where err is coming from. Refer to the issue so when it is fixed we can remove the annotation. Signed-off-by: Kir Kolyshkin --- notify_socket.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notify_socket.go b/notify_socket.go index 559340e56..34c31cc3f 100644 --- a/notify_socket.go +++ b/notify_socket.go @@ -215,7 +215,7 @@ func sdNotifyBarrier(client *net.UnixConn) error { // Probably the other end doesn't support the sd_notify_barrier protocol. logrus.Warn("Timeout after waiting 30s for barrier. Ignored.") return nil - } else if err == io.EOF { //nolint:errorlint // comparison with io.EOF is legit. + } else if err == io.EOF { //nolint:errorlint // https://github.com/polyfloyd/go-errorlint/issues/49 return nil } else { return err From 17e7e230bd52b6f6c0167be8aedb940ac7160820 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 24 Aug 2023 17:22:23 -0700 Subject: [PATCH 2/3] ci/gha: bump golangci-lint to v1.54 Currently, it is at v1.54.2. Signed-off-by: Kir Kolyshkin --- .github/workflows/validate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index f3b9e6765..4082258eb 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -40,7 +40,7 @@ jobs: sudo apt -q install libseccomp-dev - uses: golangci/golangci-lint-action@v3 with: - version: v1.53 + version: v1.54 # Extra linters, only checking new code from a pull request. - name: lint-extra if: github.event_name == 'pull_request' From f62f0bdfbf450b942491de02d8f223cdee79e0cb Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 24 Aug 2023 17:27:14 -0700 Subject: [PATCH 3/3] Remove nolint annotations for unix errno comparisons golangci-lint v1.54.2 comes with errorlint v1.4.4, which contains the fix [1] whitelisting all errno comparisons for errors coming from x/sys/unix. Thus, these annotations are no longer necessary. Hooray! [1] https://github.com/polyfloyd/go-errorlint/pull/47 Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/file.go | 2 +- libcontainer/cgroups/fs/cpuset.go | 2 +- libcontainer/cgroups/utils.go | 2 +- libcontainer/criu_linux.go | 2 +- libcontainer/init_linux.go | 2 +- libcontainer/specconv/spec_linux.go | 1 - libcontainer/system/linux.go | 2 +- signals.go | 2 +- 8 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libcontainer/cgroups/file.go b/libcontainer/cgroups/file.go index 0cdaf7478..048a0ca4b 100644 --- a/libcontainer/cgroups/file.go +++ b/libcontainer/cgroups/file.go @@ -89,7 +89,7 @@ func prepareOpenat2() error { }) if err != nil { prepErr = &os.PathError{Op: "openat2", Path: cgroupfsDir, Err: err} - if err != unix.ENOSYS { //nolint:errorlint // unix errors are bare + if err != unix.ENOSYS { logrus.Warnf("falling back to securejoin: %s", prepErr) } else { logrus.Debug("openat2 not available, falling back to securejoin") diff --git a/libcontainer/cgroups/fs/cpuset.go b/libcontainer/cgroups/fs/cpuset.go index 550baa427..fe01ba984 100644 --- a/libcontainer/cgroups/fs/cpuset.go +++ b/libcontainer/cgroups/fs/cpuset.go @@ -195,7 +195,7 @@ func cpusetEnsureParent(current string) error { } // Treat non-existing directory as cgroupfs as it will be created, // and the root cpuset directory obviously exists. - if err != nil && err != unix.ENOENT { //nolint:errorlint // unix errors are bare + if err != nil && err != unix.ENOENT { return &os.PathError{Op: "statfs", Path: parent, Err: err} } diff --git a/libcontainer/cgroups/utils.go b/libcontainer/cgroups/utils.go index 27c18b697..965c607c6 100644 --- a/libcontainer/cgroups/utils.go +++ b/libcontainer/cgroups/utils.go @@ -219,7 +219,7 @@ func PathExists(path string) bool { func rmdir(path string) error { err := unix.Rmdir(path) - if err == nil || err == unix.ENOENT { //nolint:errorlint // unix errors are bare + if err == nil || err == unix.ENOENT { return nil } return &os.PathError{Op: "rmdir", Path: path, Err: err} diff --git a/libcontainer/criu_linux.go b/libcontainer/criu_linux.go index ec6228399..9750ceaa3 100644 --- a/libcontainer/criu_linux.go +++ b/libcontainer/criu_linux.go @@ -593,7 +593,7 @@ func (c *Container) prepareCriuRestoreMounts(mounts []*configs.Mount) error { for _, u := range umounts { _ = utils.WithProcfd(c.config.Rootfs, u, func(procfd string) error { if e := unix.Unmount(procfd, unix.MNT_DETACH); e != nil { - if e != unix.EINVAL { //nolint:errorlint // unix errors are bare + if e != unix.EINVAL { // Ignore EINVAL as it means 'target is not a mount point.' // It probably has already been unmounted. logrus.Warnf("Error during cleanup unmounting of %s (%s): %v", procfd, u, e) diff --git a/libcontainer/init_linux.go b/libcontainer/init_linux.go index 7b6c8113b..30152696f 100644 --- a/libcontainer/init_linux.go +++ b/libcontainer/init_linux.go @@ -642,7 +642,7 @@ func signalAllProcesses(m cgroups.Manager, s unix.Signal) error { } for _, pid := range pids { err := unix.Kill(pid, s) - if err != nil && err != unix.ESRCH { //nolint:errorlint // unix errors are bare + if err != nil && err != unix.ESRCH { logrus.Warnf("kill %d: %v", pid, err) } } diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go index 5ccaf356e..88f9c6777 100644 --- a/libcontainer/specconv/spec_linux.go +++ b/libcontainer/specconv/spec_linux.go @@ -322,7 +322,6 @@ type CreateOpts struct { func getwd() (wd string, err error) { for { wd, err = unix.Getwd() - //nolint:errorlint // unix errors are bare if err != unix.EINTR { break } diff --git a/libcontainer/system/linux.go b/libcontainer/system/linux.go index e1d6eb180..d2ad5cea2 100644 --- a/libcontainer/system/linux.go +++ b/libcontainer/system/linux.go @@ -43,7 +43,7 @@ func Execv(cmd string, args []string, env []string) error { func Exec(cmd string, args []string, env []string) error { for { err := unix.Exec(cmd, args, env) - if err != unix.EINTR { //nolint:errorlint // unix errors are bare + if err != unix.EINTR { return &os.PathError{Op: "exec", Path: cmd, Err: err} } } diff --git a/signals.go b/signals.go index cec4cb54a..e0bc7c61c 100644 --- a/signals.go +++ b/signals.go @@ -124,7 +124,7 @@ func (h *signalHandler) reap() (exits []exit, err error) { for { pid, err := unix.Wait4(-1, &ws, unix.WNOHANG, &rus) if err != nil { - if err == unix.ECHILD { //nolint:errorlint // unix errors are bare + if err == unix.ECHILD { return exits, nil } return nil, err