From c60a3afb263145d58fda55868024748a7d690305 Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Tue, 18 Jul 2023 23:48:41 +0300 Subject: [PATCH 1/3] fpga: fix naked return error from linter golangci-lint version < v1.53.0 used nakedret linter that did not check return values in conditionals. That got changed in v1.53.0 and some of our code starts failing because of naked returns from conditionals. Update the code to get nakedret linter passing. Signed-off-by: Hyeongju Johannes Lee --- cmd/fpga_tool/fpga_tool.go | 10 +++++----- pkg/fpga/dfl_linux.go | 8 ++++---- pkg/fpga/intel_fpga_linux.go | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/fpga_tool/fpga_tool.go b/cmd/fpga_tool/fpga_tool.go index cdd36d6e8..931335998 100644 --- a/cmd/fpga_tool/fpga_tool.go +++ b/cmd/fpga_tool/fpga_tool.go @@ -118,7 +118,7 @@ func validateFlags(cmd, bitstream, device string, port uint) error { func installBitstream(fname string, dryRun, force, quiet bool) (err error) { info, err := bitstream.Open(fname) if err != nil { - return + return err } defer info.Close() @@ -129,7 +129,7 @@ func installBitstream(fname string, dryRun, force, quiet bool) (err error) { if dryRun { fmt.Println("Dry-run: no copying performed") - return + return nil } } @@ -285,21 +285,21 @@ func printFpgaPort(f fpga.Port, quiet bool) (err error) { pci, err := f.GetPCIDevice() if err != nil { - return + return err } printPCIeInfo(pci, quiet) fme, err := f.GetFME() if err != nil { - return + return err } fmt.Printf("FME Name : %s\n", fme.GetName()) num, err := f.GetPortID() if err != nil { - return + return err } fmt.Printf("Port Id : %d\n", num) diff --git a/pkg/fpga/dfl_linux.go b/pkg/fpga/dfl_linux.go index b3b661997..6f2605c76 100644 --- a/pkg/fpga/dfl_linux.go +++ b/pkg/fpga/dfl_linux.go @@ -403,7 +403,7 @@ func (f *DflPort) GetFME() (fme FME, err error) { pci, err := f.GetPCIDevice() if err != nil { - return + return nil, err } if pci.PhysFn != nil { @@ -417,17 +417,17 @@ func (f *DflPort) GetFME() (fme FME, err error) { } if err = readFilesInDirectory(fileMap, filepath.Join(pci.SysFsPath, dflFpgaFmeGlobPCI)); err != nil { - return + return nil, err } realDev, err := filepath.EvalSymlinks(filepath.Join("/dev/char", dev)) if err != nil { - return + return nil, err } fme, err = NewDflFME(realDev) if err != nil { - return + return nil, err } f.FME = fme diff --git a/pkg/fpga/intel_fpga_linux.go b/pkg/fpga/intel_fpga_linux.go index 56304fec2..13105a6af 100644 --- a/pkg/fpga/intel_fpga_linux.go +++ b/pkg/fpga/intel_fpga_linux.go @@ -408,7 +408,7 @@ func (f *IntelFpgaPort) GetFME() (fme FME, err error) { pci, err := f.GetPCIDevice() if err != nil { - return + return nil, err } if pci.PhysFn != nil { @@ -421,17 +421,17 @@ func (f *IntelFpgaPort) GetFME() (fme FME, err error) { "dev": &dev, } if err = readFilesInDirectory(fileMap, filepath.Join(pci.SysFsPath, intelFpgaFmeGlobPCI)); err != nil { - return + return nil, err } realDev, err := filepath.EvalSymlinks(filepath.Join("/dev/char", dev)) if err != nil { - return + return nil, err } fme, err = NewIntelFpgaFME(realDev) if err != nil { - return + return nil, err } f.FME = fme From 6e717325b6e3b22cf02637013b4cb17282834e8e Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Wed, 19 Jul 2023 18:33:57 +0300 Subject: [PATCH 2/3] Makefile: update versions of golangci-lint and cert-manager Signed-off-by: Hyeongju Johannes Lee --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 67fe4c5d5..2f51ae9b2 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,9 @@ BUILDTAGS ?= "" BUILDER ?= "docker" EXTRA_BUILD_ARGS ?= "" -CERT_MANAGER_VERSION ?= v1.12.0 +CERT_MANAGER_VERSION ?= v1.12.2 CONTROLLER_GEN_VERSION ?= v0.12.0 -GOLANGCI_LINT_VERSION ?= v1.52.2 +GOLANGCI_LINT_VERSION ?= v1.53.3 KIND_VERSION ?= v0.19.0 GOLICENSES_VERSION ?= v1.6.0 # Default bundle image tag From bf286c689d7c8961beb0495f5128639b664c4336 Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Wed, 19 Jul 2023 18:35:20 +0300 Subject: [PATCH 3/3] update version of controller gen to v0.12.1 Signed-off-by: Hyeongju Johannes Lee --- Makefile | 2 +- .../crd/bases/fpga.intel.com_acceleratorfunctions.yaml | 2 +- .../crd/bases/fpga.intel.com_fpgaregions.yaml | 2 +- .../crd/bases/deviceplugin.intel.com_dlbdeviceplugins.yaml | 2 +- .../crd/bases/deviceplugin.intel.com_dsadeviceplugins.yaml | 2 +- .../crd/bases/deviceplugin.intel.com_fpgadeviceplugins.yaml | 2 +- .../crd/bases/deviceplugin.intel.com_gpudeviceplugins.yaml | 2 +- .../crd/bases/deviceplugin.intel.com_iaadeviceplugins.yaml | 2 +- .../crd/bases/deviceplugin.intel.com_qatdeviceplugins.yaml | 2 +- .../crd/bases/deviceplugin.intel.com_sgxdeviceplugins.yaml | 2 +- .../operator/crd/bases/fpga.intel.com_acceleratorfunctions.yaml | 2 +- deployments/operator/crd/bases/fpga.intel.com_fpgaregions.yaml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 2f51ae9b2..65d293fb1 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ BUILDER ?= "docker" EXTRA_BUILD_ARGS ?= "" CERT_MANAGER_VERSION ?= v1.12.2 -CONTROLLER_GEN_VERSION ?= v0.12.0 +CONTROLLER_GEN_VERSION ?= v0.12.1 GOLANGCI_LINT_VERSION ?= v1.53.3 KIND_VERSION ?= v0.19.0 GOLICENSES_VERSION ?= v1.6.0 diff --git a/deployments/fpga_admissionwebhook/crd/bases/fpga.intel.com_acceleratorfunctions.yaml b/deployments/fpga_admissionwebhook/crd/bases/fpga.intel.com_acceleratorfunctions.yaml index 8378615ca..ce65e4884 100644 --- a/deployments/fpga_admissionwebhook/crd/bases/fpga.intel.com_acceleratorfunctions.yaml +++ b/deployments/fpga_admissionwebhook/crd/bases/fpga.intel.com_acceleratorfunctions.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: acceleratorfunctions.fpga.intel.com spec: group: fpga.intel.com diff --git a/deployments/fpga_admissionwebhook/crd/bases/fpga.intel.com_fpgaregions.yaml b/deployments/fpga_admissionwebhook/crd/bases/fpga.intel.com_fpgaregions.yaml index 4892b1337..114d75a0e 100644 --- a/deployments/fpga_admissionwebhook/crd/bases/fpga.intel.com_fpgaregions.yaml +++ b/deployments/fpga_admissionwebhook/crd/bases/fpga.intel.com_fpgaregions.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: fpgaregions.fpga.intel.com spec: group: fpga.intel.com diff --git a/deployments/operator/crd/bases/deviceplugin.intel.com_dlbdeviceplugins.yaml b/deployments/operator/crd/bases/deviceplugin.intel.com_dlbdeviceplugins.yaml index c501c7bdd..ab4b90203 100644 --- a/deployments/operator/crd/bases/deviceplugin.intel.com_dlbdeviceplugins.yaml +++ b/deployments/operator/crd/bases/deviceplugin.intel.com_dlbdeviceplugins.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: dlbdeviceplugins.deviceplugin.intel.com spec: group: deviceplugin.intel.com diff --git a/deployments/operator/crd/bases/deviceplugin.intel.com_dsadeviceplugins.yaml b/deployments/operator/crd/bases/deviceplugin.intel.com_dsadeviceplugins.yaml index 88cd931fc..996e119e5 100644 --- a/deployments/operator/crd/bases/deviceplugin.intel.com_dsadeviceplugins.yaml +++ b/deployments/operator/crd/bases/deviceplugin.intel.com_dsadeviceplugins.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: dsadeviceplugins.deviceplugin.intel.com spec: group: deviceplugin.intel.com diff --git a/deployments/operator/crd/bases/deviceplugin.intel.com_fpgadeviceplugins.yaml b/deployments/operator/crd/bases/deviceplugin.intel.com_fpgadeviceplugins.yaml index 36973c609..f6868f71a 100644 --- a/deployments/operator/crd/bases/deviceplugin.intel.com_fpgadeviceplugins.yaml +++ b/deployments/operator/crd/bases/deviceplugin.intel.com_fpgadeviceplugins.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: fpgadeviceplugins.deviceplugin.intel.com spec: group: deviceplugin.intel.com diff --git a/deployments/operator/crd/bases/deviceplugin.intel.com_gpudeviceplugins.yaml b/deployments/operator/crd/bases/deviceplugin.intel.com_gpudeviceplugins.yaml index ad152aa34..4f90c4b47 100644 --- a/deployments/operator/crd/bases/deviceplugin.intel.com_gpudeviceplugins.yaml +++ b/deployments/operator/crd/bases/deviceplugin.intel.com_gpudeviceplugins.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: gpudeviceplugins.deviceplugin.intel.com spec: group: deviceplugin.intel.com diff --git a/deployments/operator/crd/bases/deviceplugin.intel.com_iaadeviceplugins.yaml b/deployments/operator/crd/bases/deviceplugin.intel.com_iaadeviceplugins.yaml index 6852a98d8..421812e1d 100644 --- a/deployments/operator/crd/bases/deviceplugin.intel.com_iaadeviceplugins.yaml +++ b/deployments/operator/crd/bases/deviceplugin.intel.com_iaadeviceplugins.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: iaadeviceplugins.deviceplugin.intel.com spec: group: deviceplugin.intel.com diff --git a/deployments/operator/crd/bases/deviceplugin.intel.com_qatdeviceplugins.yaml b/deployments/operator/crd/bases/deviceplugin.intel.com_qatdeviceplugins.yaml index 7a8ac8fe7..d0e3f49e1 100644 --- a/deployments/operator/crd/bases/deviceplugin.intel.com_qatdeviceplugins.yaml +++ b/deployments/operator/crd/bases/deviceplugin.intel.com_qatdeviceplugins.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: qatdeviceplugins.deviceplugin.intel.com spec: group: deviceplugin.intel.com diff --git a/deployments/operator/crd/bases/deviceplugin.intel.com_sgxdeviceplugins.yaml b/deployments/operator/crd/bases/deviceplugin.intel.com_sgxdeviceplugins.yaml index 6a98b4123..e6beceeee 100644 --- a/deployments/operator/crd/bases/deviceplugin.intel.com_sgxdeviceplugins.yaml +++ b/deployments/operator/crd/bases/deviceplugin.intel.com_sgxdeviceplugins.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: sgxdeviceplugins.deviceplugin.intel.com spec: group: deviceplugin.intel.com diff --git a/deployments/operator/crd/bases/fpga.intel.com_acceleratorfunctions.yaml b/deployments/operator/crd/bases/fpga.intel.com_acceleratorfunctions.yaml index 8378615ca..ce65e4884 100644 --- a/deployments/operator/crd/bases/fpga.intel.com_acceleratorfunctions.yaml +++ b/deployments/operator/crd/bases/fpga.intel.com_acceleratorfunctions.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: acceleratorfunctions.fpga.intel.com spec: group: fpga.intel.com diff --git a/deployments/operator/crd/bases/fpga.intel.com_fpgaregions.yaml b/deployments/operator/crd/bases/fpga.intel.com_fpgaregions.yaml index 4892b1337..114d75a0e 100644 --- a/deployments/operator/crd/bases/fpga.intel.com_fpgaregions.yaml +++ b/deployments/operator/crd/bases/fpga.intel.com_fpgaregions.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.12.0 + controller-gen.kubebuilder.io/version: v0.12.1 name: fpgaregions.fpga.intel.com spec: group: fpga.intel.com