From a36330d8107ab8ba0e3d9d2ab7edde0eb31ed0be Mon Sep 17 00:00:00 2001 From: Mikko Ylinen Date: Mon, 26 Aug 2024 09:18:03 +0300 Subject: [PATCH 1/3] build: use Go 1.23.0 Signed-off-by: Mikko Ylinen --- Makefile | 2 +- build/docker/intel-deviceplugin-operator.Dockerfile | 2 +- build/docker/intel-dlb-initcontainer.Dockerfile | 2 +- build/docker/intel-dlb-plugin.Dockerfile | 2 +- build/docker/intel-dsa-plugin.Dockerfile | 2 +- build/docker/intel-fpga-admissionwebhook.Dockerfile | 2 +- build/docker/intel-fpga-initcontainer.Dockerfile | 2 +- build/docker/intel-fpga-plugin.Dockerfile | 2 +- build/docker/intel-gpu-fakedev.Dockerfile | 2 +- build/docker/intel-gpu-initcontainer.Dockerfile | 2 +- build/docker/intel-gpu-plugin.Dockerfile | 2 +- build/docker/intel-iaa-plugin.Dockerfile | 2 +- build/docker/intel-qat-initcontainer.Dockerfile | 2 +- build/docker/intel-qat-plugin-kerneldrv.Dockerfile | 2 +- build/docker/intel-qat-plugin.Dockerfile | 2 +- build/docker/intel-sgx-admissionwebhook.Dockerfile | 2 +- build/docker/intel-sgx-initcontainer.Dockerfile | 2 +- build/docker/intel-sgx-plugin.Dockerfile | 2 +- build/docker/intel-xpumanager-sidecar.Dockerfile | 2 +- build/docker/lib/golang_base.docker | 2 +- go.mod | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 27771989a..3e3b82bd8 100644 --- a/Makefile +++ b/Makefile @@ -176,7 +176,7 @@ e2e-spr: pre-pull: ifeq ($(TAG),devel) - @$(BUILDER) pull golang:1.22-bookworm + @$(BUILDER) pull golang:1.23-bookworm @$(BUILDER) pull debian:unstable-slim @$(BUILDER) pull ubuntu:22.04 endif diff --git a/build/docker/intel-deviceplugin-operator.Dockerfile b/build/docker/intel-deviceplugin-operator.Dockerfile index 869a78365..ba373c1fd 100644 --- a/build/docker/intel-deviceplugin-operator.Dockerfile +++ b/build/docker/intel-deviceplugin-operator.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-dlb-initcontainer.Dockerfile b/build/docker/intel-dlb-initcontainer.Dockerfile index f5325f0aa..41adf8f73 100644 --- a/build/docker/intel-dlb-initcontainer.Dockerfile +++ b/build/docker/intel-dlb-initcontainer.Dockerfile @@ -33,7 +33,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-dlb-plugin.Dockerfile b/build/docker/intel-dlb-plugin.Dockerfile index 2b0d8fa3b..1ff94a718 100644 --- a/build/docker/intel-dlb-plugin.Dockerfile +++ b/build/docker/intel-dlb-plugin.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-dsa-plugin.Dockerfile b/build/docker/intel-dsa-plugin.Dockerfile index a24c7e340..9d92332f4 100644 --- a/build/docker/intel-dsa-plugin.Dockerfile +++ b/build/docker/intel-dsa-plugin.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-fpga-admissionwebhook.Dockerfile b/build/docker/intel-fpga-admissionwebhook.Dockerfile index 9d03d6e10..c3166e736 100644 --- a/build/docker/intel-fpga-admissionwebhook.Dockerfile +++ b/build/docker/intel-fpga-admissionwebhook.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-fpga-initcontainer.Dockerfile b/build/docker/intel-fpga-initcontainer.Dockerfile index 9b5c736ea..dbb29527e 100644 --- a/build/docker/intel-fpga-initcontainer.Dockerfile +++ b/build/docker/intel-fpga-initcontainer.Dockerfile @@ -33,7 +33,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-fpga-plugin.Dockerfile b/build/docker/intel-fpga-plugin.Dockerfile index 703ac975c..de2630b60 100644 --- a/build/docker/intel-fpga-plugin.Dockerfile +++ b/build/docker/intel-fpga-plugin.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-gpu-fakedev.Dockerfile b/build/docker/intel-gpu-fakedev.Dockerfile index 2098b71c6..b72c15767 100644 --- a/build/docker/intel-gpu-fakedev.Dockerfile +++ b/build/docker/intel-gpu-fakedev.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-gpu-initcontainer.Dockerfile b/build/docker/intel-gpu-initcontainer.Dockerfile index 94673953e..0fc51f37b 100644 --- a/build/docker/intel-gpu-initcontainer.Dockerfile +++ b/build/docker/intel-gpu-initcontainer.Dockerfile @@ -33,7 +33,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-gpu-plugin.Dockerfile b/build/docker/intel-gpu-plugin.Dockerfile index e59900b7d..2f53f35a4 100644 --- a/build/docker/intel-gpu-plugin.Dockerfile +++ b/build/docker/intel-gpu-plugin.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-iaa-plugin.Dockerfile b/build/docker/intel-iaa-plugin.Dockerfile index b11f17b71..9ea38944e 100644 --- a/build/docker/intel-iaa-plugin.Dockerfile +++ b/build/docker/intel-iaa-plugin.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-qat-initcontainer.Dockerfile b/build/docker/intel-qat-initcontainer.Dockerfile index 336f3e947..30cff41dd 100644 --- a/build/docker/intel-qat-initcontainer.Dockerfile +++ b/build/docker/intel-qat-initcontainer.Dockerfile @@ -33,7 +33,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-qat-plugin-kerneldrv.Dockerfile b/build/docker/intel-qat-plugin-kerneldrv.Dockerfile index 7ff34761f..b8a0f3788 100644 --- a/build/docker/intel-qat-plugin-kerneldrv.Dockerfile +++ b/build/docker/intel-qat-plugin-kerneldrv.Dockerfile @@ -33,7 +33,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-qat-plugin.Dockerfile b/build/docker/intel-qat-plugin.Dockerfile index 21e997d68..2e6a3cf2b 100644 --- a/build/docker/intel-qat-plugin.Dockerfile +++ b/build/docker/intel-qat-plugin.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-sgx-admissionwebhook.Dockerfile b/build/docker/intel-sgx-admissionwebhook.Dockerfile index f02197dbc..431290c40 100644 --- a/build/docker/intel-sgx-admissionwebhook.Dockerfile +++ b/build/docker/intel-sgx-admissionwebhook.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-sgx-initcontainer.Dockerfile b/build/docker/intel-sgx-initcontainer.Dockerfile index 8d2025cb5..bb78c700f 100644 --- a/build/docker/intel-sgx-initcontainer.Dockerfile +++ b/build/docker/intel-sgx-initcontainer.Dockerfile @@ -33,7 +33,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-sgx-plugin.Dockerfile b/build/docker/intel-sgx-plugin.Dockerfile index d71661fab..3e1a9045b 100644 --- a/build/docker/intel-sgx-plugin.Dockerfile +++ b/build/docker/intel-sgx-plugin.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/intel-xpumanager-sidecar.Dockerfile b/build/docker/intel-xpumanager-sidecar.Dockerfile index 5a557bb25..16b981043 100644 --- a/build/docker/intel-xpumanager-sidecar.Dockerfile +++ b/build/docker/intel-xpumanager-sidecar.Dockerfile @@ -34,7 +34,7 @@ ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### FROM ${GOLANG_BASE} as builder ARG DIR=/intel-device-plugins-for-kubernetes diff --git a/build/docker/lib/golang_base.docker b/build/docker/lib/golang_base.docker index df24963cd..47a5fbbbf 100644 --- a/build/docker/lib/golang_base.docker +++ b/build/docker/lib/golang_base.docker @@ -5,5 +5,5 @@ ## ## This is used on release branches before tagging a stable version. ## The main branch defaults to using the latest Golang base image. -ARG GOLANG_BASE=golang:1.22-bookworm +ARG GOLANG_BASE=golang:1.23-bookworm ### diff --git a/go.mod b/go.mod index d652ddc67..f1fc5cd0b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/intel/intel-device-plugins-for-kubernetes -go 1.22.0 +go 1.23.0 require ( github.com/fsnotify/fsnotify v1.7.0 From fa6d027b246c1bbbc2ee9e6f6a65dec41e1cb25f Mon Sep 17 00:00:00 2001 From: Tuomas Katila Date: Mon, 19 Aug 2024 15:26:30 +0300 Subject: [PATCH 2/3] Fix some lint errors Signed-off-by: Tuomas Katila --- cmd/gpu_plugin/gpu_plugin_test.go | 4 ++-- pkg/idxd/plugin_test.go | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/gpu_plugin/gpu_plugin_test.go b/cmd/gpu_plugin/gpu_plugin_test.go index e0ecd6b24..230e0629f 100644 --- a/cmd/gpu_plugin/gpu_plugin_test.go +++ b/cmd/gpu_plugin/gpu_plugin_test.go @@ -589,7 +589,7 @@ func createBypathTestFiles(t *testing.T, card, root, linkFile string, bypathFile t.Fatal("Couldn't create test drm dir", err) } - if err := os.WriteFile(devPath, []byte{0}, os.ModePerm); err != nil { + if err := os.WriteFile(devPath, []byte{0}, 0o600); err != nil { t.Fatal("Couldn't create card file", err) } @@ -604,7 +604,7 @@ func createBypathTestFiles(t *testing.T, card, root, linkFile string, bypathFile } for _, f := range bypathFiles { - if err := os.WriteFile(path.Join(byPath, f), []byte{1}, os.ModePerm); err != nil { + if err := os.WriteFile(path.Join(byPath, f), []byte{1}, 0o600); err != nil { t.Fatal("WriteFile failed:", path.Join(byPath, f)) } } diff --git a/pkg/idxd/plugin_test.go b/pkg/idxd/plugin_test.go index 92d4cf841..45116d9d7 100644 --- a/pkg/idxd/plugin_test.go +++ b/pkg/idxd/plugin_test.go @@ -39,7 +39,10 @@ func getFakeDevNodes(devDir, charDevDir, wqName string) ([]pluginapi.DeviceSpec, var devNum, queueNum int - fmt.Sscanf(wqName, "wq%d.%d", &devNum, &queueNum) + if _, err := fmt.Sscanf(wqName, "wq%d.%d", &devNum, &queueNum); err != nil { + return []pluginapi.DeviceSpec{}, err + } + charDevPath := path.Join(charDevDir, fmt.Sprintf("%d:%d", dsaMajor, devNum*10+queueNum)) return []pluginapi.DeviceSpec{ From 7e5b280cd1092977bce7ac286273187732701b8b Mon Sep 17 00:00:00 2001 From: Tuomas Katila Date: Thu, 22 Aug 2024 14:00:03 +0300 Subject: [PATCH 3/3] golanci-lint: upgrade to 1.60.3, fix one issue and ignore conversion errors Signed-off-by: Tuomas Katila --- .github/workflows/lib-validate.yaml | 2 +- .golangci.yml | 7 +++++-- Makefile | 2 +- cmd/internal/labeler/labeler_test.go | 1 - 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lib-validate.yaml b/.github/workflows/lib-validate.yaml index 56adc380c..851534761 100644 --- a/.github/workflows/lib-validate.yaml +++ b/.github/workflows/lib-validate.yaml @@ -42,7 +42,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6 with: - version: v1.57.2 + version: v1.60.3 args: -v --timeout 5m build: name: Build and check device plugins diff --git a/.golangci.yml b/.golangci.yml index 3c5f1c62d..896c2ea87 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,12 +12,12 @@ linters: - bodyclose - dogsled - errcheck - - exportloopref + - copyloopvar - gocognit - goconst - gocyclo - godot - - goerr113 + - err113 - gofmt - goimports - gomodguard @@ -62,6 +62,9 @@ linters-settings: issues: exclude-rules: + - linters: + - gosec + text: "G115" - path: _test\.go linters: - gocognit diff --git a/Makefile b/Makefile index 3e3b82bd8..7ea7d29be 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ EXTRA_BUILD_ARGS ?= "" CERT_MANAGER_VERSION ?= v1.15.2 CONTROLLER_GEN_VERSION ?= v0.16.1 -GOLANGCI_LINT_VERSION ?= v1.57.2 +GOLANGCI_LINT_VERSION ?= v1.60.3 KIND_VERSION ?= v0.23.0 GOLICENSES_VERSION ?= v1.6.0 # Default bundle image tag diff --git a/cmd/internal/labeler/labeler_test.go b/cmd/internal/labeler/labeler_test.go index e3dd50bef..7725307e3 100644 --- a/cmd/internal/labeler/labeler_test.go +++ b/cmd/internal/labeler/labeler_test.go @@ -638,7 +638,6 @@ func TestLabeling(t *testing.T) { t.Fatalf("can't create temporary subroot directory: %+v", err) } - tc := tc t.Run(tc.name, func(t *testing.T) { err := os.MkdirAll(path.Join(subroot, "0"), 0750) if err != nil {