From 9e7a0db38aa208c750026a7117d4523391524ee1 Mon Sep 17 00:00:00 2001 From: Raul Sevilla Date: Fri, 30 Aug 2024 12:32:21 +0200 Subject: [PATCH 1/2] Fix golangci-lint precommit hook Signed-off-by: Raul Sevilla --- .pre-commit-config.yaml | 3 ++- cluster_health.go | 2 +- egressip.go | 6 ++---- index.go | 20 ++++++++++---------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2244782d..111b468b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,9 @@ repos: - repo: https://github.com/golangci/golangci-lint - rev: v1.58.1 + rev: v1.55.2 hooks: - id: golangci-lint + entry: golangci-lint run args: [--timeout=5m] - repo: https://github.com/igorshubovych/markdownlint-cli rev: v0.34.0 diff --git a/cluster_health.go b/cluster_health.go index 652226c8..d60dfa34 100644 --- a/cluster_health.go +++ b/cluster_health.go @@ -100,7 +100,7 @@ func clusterImageRegistryCheck(clientset kubernetes.Interface) bool { return false } if deployment.Status.AvailableReplicas > 0 { - log.Debugf("Deployment image-regsitry in namespace openshift-image-registry is available with %d replicas", deployment.Status.AvailableReplicas) + log.Debugf("Deployment image-registry in namespace openshift-image-registry is available with %d replicas", deployment.Status.AvailableReplicas) return true } return false diff --git a/egressip.go b/egressip.go index 42845e38..feb38e58 100644 --- a/egressip.go +++ b/egressip.go @@ -102,19 +102,18 @@ func getFirstUsableAddr(cidr string) uint32 { baseAddrInt, err := ipconv.IPv4ToInt(firstUsableIP) if err != nil { log.Fatal("Error converting IP to int: ", err) - os.Exit(1) } return baseAddrInt } -// egress IPs and node IPs will be in same cidr. So we need to exclude node IPs from CIDR to generate list of avaialble egress IPs. +// egress IPs and node IPs will be in same cidr. So we need to exclude node IPs from CIDR to generate list of available egress IPs. func generateEgressIPs(numJobIterations int, addressesPerIteration int, externalServerIP string) { nodeIPs, egressIPCidr := getEgressIPCidrNodeIPs() // Add external server ip to nodeIPs to get excluded while creating egress ip list nodeIPs = append(nodeIPs, externalServerIP) baseAddrInt := getFirstUsableAddr(egressIPCidr) - // list to host avaialble egress IPs + // list to host available egress IPs addrSlice := make([]string, 0, (numJobIterations * addressesPerIteration)) // map to store nodeIPs @@ -123,7 +122,6 @@ func generateEgressIPs(numJobIterations int, addressesPerIteration int, external nodeipuint32, err := ipconv.IPv4ToInt(net.ParseIP(nodeip)) if err != nil { log.Fatal("Error: ", err) - os.Exit(1) } nodeMap[nodeipuint32] = true } diff --git a/index.go b/index.go index 545e0c8e..1f7e0831 100644 --- a/index.go +++ b/index.go @@ -15,17 +15,17 @@ package ocp import ( + "encoding/json" + "fmt" "os" "strings" - "encoding/json" "time" - "fmt" "github.com/cloud-bulldozer/go-commons/indexers" - "github.com/cloud-bulldozer/go-commons/version" ocpmetadata "github.com/cloud-bulldozer/go-commons/ocp-metadata" - "github.com/kube-burner/kube-burner/pkg/config" + "github.com/cloud-bulldozer/go-commons/version" "github.com/kube-burner/kube-burner/pkg/burner" + "github.com/kube-burner/kube-burner/pkg/config" "github.com/kube-burner/kube-burner/pkg/prometheus" "github.com/kube-burner/kube-burner/pkg/util/metrics" "github.com/kube-burner/kube-burner/pkg/workloads" @@ -133,17 +133,17 @@ func NewIndex(metricsEndpoint *string, ocpMetaAgent *ocpmetadata.Metadata) *cobr break } jobSummary := burner.JobSummary{ - Timestamp: time.Unix(start, 0).UTC(), + Timestamp: time.Unix(start, 0).UTC(), EndTimestamp: time.Unix(end, 0).UTC(), - ElapsedTime: time.Unix(end, 0).UTC().Sub(time.Unix(start, 0).UTC()).Round(time.Second).Seconds(), - UUID: uuid, + ElapsedTime: time.Unix(end, 0).UTC().Sub(time.Unix(start, 0).UTC()).Round(time.Second).Seconds(), + UUID: uuid, JobConfig: config.Job{ Name: jobName, }, - Metadata: metricsScraper.Metadata, + Metadata: metricsScraper.Metadata, MetricName: "jobSummary", - Version: fmt.Sprintf("%v@%v", version.Version, version.GitCommit), - Passed: rc == 0, + Version: fmt.Sprintf("%v@%v", version.Version, version.GitCommit), + Passed: rc == 0, } burner.IndexJobSummary([]burner.JobSummary{jobSummary}, indexerValue) }, From 2ae9f3f440220965a939c697f50a0e99e3f0b482 Mon Sep 17 00:00:00 2001 From: Raul Sevilla Date: Tue, 3 Sep 2024 15:20:36 +0200 Subject: [PATCH 2/2] Disable revive Disabling revive due to false positives: ``` $ make lint Executing pre-commit for all files pre-commit run --all-files [INFO] Initializing environment for https://github.com/golangci/golangci-lint. [INFO] Installing environment for https://github.com/golangci/golangci-lint. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... golangci-lint............................................................Failed - hook id: golangci-lint - exit code: 1 WARN [config_reader] The configuration option `linters.errcheck.ignore` is deprecated, please use `linters.errcheck.exclude-functions`. crd-scale.go:32:16: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive) PreRun: func(cmd *cobra.Command, args []string) { ^ crd-scale.go:35:33: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive) Run: func(cmd *cobra.Command, args []string) { ^ node-density-cni.go:39:16: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive) PreRun: func(cmd *cobra.Command, args []string) { ^ egressip.go:155:16: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive) PreRun: func(cmd *cobra.Command, args []string) { ^ node-density-cni.go:51:33: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive) Run: func(cmd *cobra.Command, args []string) { ^ egressip.go:162:33: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive) Run: func(cmd *cobra.Command, args []string) { ^ ``` Signed-off-by: Raul Sevilla --- .golangci.yml | 1 - .pre-commit-config.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 67e6065f..e943427d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,7 +14,6 @@ linters: - goimports - dupl - unparam - - revive - staticcheck - gosimple - unconvert diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 111b468b..4725904a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/golangci/golangci-lint - rev: v1.55.2 + rev: v1.60.3 hooks: - id: golangci-lint entry: golangci-lint run