Skip to content

CNF-23398: Upgrade golangci-lint from v1.54.2 to v2.12.2#692

Open
sebrandon1 wants to merge 1 commit into
openshift:masterfrom
sebrandon1:golangci-lint-v2-upgrade
Open

CNF-23398: Upgrade golangci-lint from v1.54.2 to v2.12.2#692
sebrandon1 wants to merge 1 commit into
openshift:masterfrom
sebrandon1:golangci-lint-v2-upgrade

Conversation

@sebrandon1
Copy link
Copy Markdown
Member

@sebrandon1 sebrandon1 commented Jan 16, 2026

Summary

  • Upgrade golangci-lint from v1.54.2 to v2.12.2
  • Update module path to use /v2/ prefix
  • Add .golangci.yml with v2 version declaration

Changes Made

  • Makefile: Updated GOLANGCI_LINT_VERSION from v1.54.2 to v2.12.2 and module path to /v2/
  • .golangci.yml: Created with v2 version declaration

Test plan

  • CI linting passes with golangci-lint v2
  • No new linting errors introduced

Tracking: redhat-best-practices-for-k8s/telco-bot#49

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 16, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a new GolangCI-Lint configuration (.golangci.yml) and updates the Makefile to use golangci-lint v2 (version set to v2.11.4 and install path updated to the v2 module path).

Changes

GolangCI-Lint upgrade & config

Layer / File(s) Summary
Data Shape / Config
./.golangci.yml
New file added with version: "2" and run.timeout: 5m.
Version Bump
Makefile
GOLANGCI_LINT_VERSION changed to v2.11.4.
Tooling Wiring
Makefile
prereqs recipe updated go install path to github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} and checks/install preserved.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Stable And Deterministic Test Names ❌ Error Three Ginkgo test names use dynamic content: loop variable 's' at ingressnodefirewall_controller_rules_test.go:754 and node name at ingressnodefirewallnodestate_controller_test.go:107-108. Replace fmt.Sprintf calls with static descriptive text. Move dynamic variables from test titles to test body.
✅ Passed checks (11 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Test Structure And Quality ✅ Passed PR modifies only .golangci.yml and Makefile (tooling/config files), not Ginkgo test code. The check for test structure is not applicable.
Microshift Test Compatibility ✅ Passed PR only modifies build config files (.golangci.yml, Makefile); no Ginkgo e2e tests are added. MicroShift check applies only when new tests are added, so it's not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR upgrades golangci-lint from v1 to v2 (updates Makefile and .golangci.yml). No new Ginkgo e2e tests are added, so the SNO compatibility check does not apply.
Topology-Aware Scheduling Compatibility ✅ Passed PR changes only build tool configuration (Makefile, .golangci.yml), not deployment manifests, operator code, or controllers. Custom check is not applicable.
Ote Binary Stdout Contract ✅ Passed PR changes are infrastructure-only (.golangci.yml config and Makefile build tool versions) with no modifications to process-level source code that would emit stdout to the OTE binary.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No Ginkgo e2e tests are added in this PR. Changes are only to .golangci.yml (linting config) and Makefile (build config for golangci-lint upgrade v1.54.2→v2.11.4).
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: upgrading golangci-lint from v1.54.2 to v2.x, which is the primary objective of the pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Jan 16, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sebrandon1
Once this PR has been reviewed and has the lgtm label, please assign knobunc for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@Makefile`:
- Line 423: The Makefile pins GOLANGCI_LINT_VERSION = v2.0.2 but hack/lint.sh
still sets VERSION=v1.54.2, causing inconsistent lint runs; update the VERSION
variable in hack/lint.sh from v1.54.2 to v2.0.2 so the script pulls the same
golangci-lint image as the Makefile (look for the VERSION= assignment near the
top of hack/lint.sh and change it to VERSION=v2.0.2).
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 1223118 and a18219c.

📒 Files selected for processing (2)
  • .golangci.yml
  • Makefile
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • Makefile
🔇 Additional comments (2)
Makefile (1)

432-432: Verify prereqs still finds the v2 binary in your environments.

Line 432 still checks $(shell go env GOPATH)/bin; if CI or local dev uses GOBIN, confirm the guard and PATH align so the v2 binary is discovered and not reinstalled unnecessarily.

.golangci.yml (1)

1-3: Config is minimal and aligned with v2; ensure CI runs golangci-lint ≥ 2.0.

Line 1 introduces version: "2", which v1 will reject; please verify all lint invocations use the v2 binary.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread Makefile Outdated

CILIUM_EBPF_VERSION := v0.18.0
GOLANGCI_LINT_VERSION = v1.54.2
GOLANGCI_LINT_VERSION = v2.0.2
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for remaining v1 references and v1.54.2 version pins
echo "=== Searching for v1.54.2 references ==="
rg -n 'v1\.54\.2'

echo "=== Searching for v1 binary path references ==="
rg -n 'golangci-lint/cmd/golangci-lint'

echo "=== Checking Makefile for golangci-lint references ==="
rg -n -A2 -B2 'GOLANGCI_LINT' Makefile

echo "=== Looking for CI scripts that may reference golangci-lint ==="
fd -t f '(lint|ci|github)' hack/ | head -20

Repository: openshift/ingress-node-firewall

Length of output: 1056


🏁 Script executed:

#!/bin/bash
# Check hack/lint.sh to understand the version impact
echo "=== Content of hack/lint.sh ==="
cat -n hack/lint.sh

echo ""
echo "=== Search for references to hack/lint.sh in CI workflows ==="
fd -t f '\.(yml|yaml)' .github/workflows/ 2>/dev/null | while read f; do
  if rg -l 'hack/lint' "$f" 2>/dev/null; then
    echo "Found in: $f"
    rg -n 'hack/lint' "$f"
  fi
done

echo ""
echo "=== Check if hack/lint.sh is referenced elsewhere ==="
rg -l 'hack/lint'

Repository: openshift/ingress-node-firewall

Length of output: 813


🏁 Script executed:

#!/bin/bash
# Check if hack/lint.sh is actively maintained/referenced in Makefile targets
echo "=== Check Makefile for hack/lint.sh usage ==="
rg -n 'hack/lint' Makefile

echo ""
echo "=== Check for any documentation/comments about hack/lint.sh usage ==="
rg -B2 -A2 'hack/lint' README* 2>/dev/null || echo "No README references found"

echo ""
echo "=== Check if hack/lint.sh target exists in Makefile ==="
rg -n '^lint:' Makefile

Repository: openshift/ingress-node-firewall

Length of output: 379


Update hack/lint.sh to use golangci-lint v2.0.2 to match Makefile pin.

The v1.54.2 container image reference at hack/lint.sh:6 conflicts with the v2.0.2 version pinned in Makefile:423. Since the make lint target calls hack/lint.sh, developers using that command get inconsistent linting behavior. Update VERSION=v1.54.2 to VERSION=v2.0.2 in hack/lint.sh.

🤖 Prompt for AI Agents
In `@Makefile` at line 423, The Makefile pins GOLANGCI_LINT_VERSION = v2.0.2 but
hack/lint.sh still sets VERSION=v1.54.2, causing inconsistent lint runs; update
the VERSION variable in hack/lint.sh from v1.54.2 to v2.0.2 so the script pulls
the same golangci-lint image as the Makefile (look for the VERSION= assignment
near the top of hack/lint.sh and change it to VERSION=v2.0.2).

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
Makefile (1)

423-432: ⚠️ Potential issue | 🟠 Major

Align lint execution with the v2.11.4 upgrade.

Makefile now pins/install-paths golangci-lint v2, but make lint still calls hack/lint.sh, which remains pinned to v1.54.2 (Line 6 in hack/lint.sh). This keeps lint behavior inconsistent with the upgrade objective.

#!/bin/bash
# Verify golangci-lint version consistency between Makefile and lint script
rg -n 'GOLANGCI_LINT_VERSION|golangci-lint/v2/cmd/golangci-lint|^\s*lint:' Makefile
rg -n 'VERSION=|golangci/golangci-lint:' hack/lint.sh

Expected: hack/lint.sh and Makefile should both reference the same golangci-lint v2 version.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 423 - 432, Makefile now installs golangci-lint using
GOLANGCI_LINT_VERSION (v2.11.4) but hack/lint.sh still pins v1.54.2; update
hack/lint.sh to reference the same v2 version or read GOLANGCI_LINT_VERSION
(e.g., set VERSION to v2.11.4 or switch install lines from
github.com/golangci/golangci-lint@v1.54.2 to
github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}),
and ensure the Makefile lint target invokes the prereqs or otherwise uses the
same variable so both the Makefile (GOLANGCI_LINT_VERSION) and hack/lint.sh are
consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@Makefile`:
- Around line 423-432: Makefile now installs golangci-lint using
GOLANGCI_LINT_VERSION (v2.11.4) but hack/lint.sh still pins v1.54.2; update
hack/lint.sh to reference the same v2 version or read GOLANGCI_LINT_VERSION
(e.g., set VERSION to v2.11.4 or switch install lines from
github.com/golangci/golangci-lint@v1.54.2 to
github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}),
and ensure the Makefile lint target invokes the prereqs or otherwise uses the
same variable so both the Makefile (GOLANGCI_LINT_VERSION) and hack/lint.sh are
consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f4d9e5ee-02ca-4d8e-9f40-2d89fef88127

📥 Commits

Reviewing files that changed from the base of the PR and between a18219c and baf78b8.

📒 Files selected for processing (1)
  • Makefile

@sebrandon1 sebrandon1 force-pushed the golangci-lint-v2-upgrade branch from baf78b8 to 3d1c1a6 Compare April 30, 2026 19:28
@sebrandon1 sebrandon1 changed the title Upgrade golangci-lint from v1 to v2 Upgrade golangci-lint from v1.54.2 to v2.11.4 Apr 30, 2026
@sebrandon1 sebrandon1 changed the title Upgrade golangci-lint from v1.54.2 to v2.11.4 CNF-23398: Upgrade golangci-lint from v1.54.2 to v2.11.4 Apr 30, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 30, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 30, 2026

@sebrandon1: This pull request references CNF-23398 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Update golangci-lint from v1.54.2 to v2.0.2
  • Update module path to use /v2/ prefix
  • Add .golangci.yml with v2 version declaration

Changes Made

  • Makefile: Updated version variable and module path
  • .golangci.yml: Created with v2 version declaration

Test plan

  • CI linting passes with golangci-lint v2
  • No new linting errors introduced

Tracking: redhat-best-practices-for-k8s/telco-bot#49

Summary by CodeRabbit

  • Chores
  • Updated linting configuration to the newer linter configuration format and increased linting timeout.
  • Bumped golangci-lint to v2.11.4 and adjusted installation path to match the v2 tool.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@sebrandon1 sebrandon1 force-pushed the golangci-lint-v2-upgrade branch from 3d1c1a6 to 3be6177 Compare May 5, 2026 22:37
@sebrandon1
Copy link
Copy Markdown
Member Author

/retest

@sebrandon1 sebrandon1 force-pushed the golangci-lint-v2-upgrade branch from 3be6177 to 59b0c3e Compare May 20, 2026 21:50
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Makefile`:
- Line 431: The Makefile currently checks for golangci-lint only under $(shell
go env GOPATH)/bin causing installs when GOBIN is set; update the existence
check to use $(or $(GOBIN),$(shell go env GOPATH)/bin)/golangci-lint (or
equivalent shell logic) so it prefers $(GOBIN) when present, then fallbacks to
GOPATH/bin, and keep the install command using ${GOLANGCI_LINT_VERSION}
unchanged; specifically modify the test command that references $(shell go env
GOPATH)/bin/golangci-lint to use the computed bin dir via $(or $(GOBIN),$(shell
go env GOPATH)/bin)/golangci-lint.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 9264fd52-a635-45d4-ac2b-97321049e457

📥 Commits

Reviewing files that changed from the base of the PR and between 3be6177 and 59b0c3e.

📒 Files selected for processing (2)
  • .golangci.yml
  • Makefile
✅ Files skipped from review due to trivial changes (1)
  • .golangci.yml

Comment thread Makefile
.PHONY: prereqs
prereqs: ## Check if prerequisites are met, and installing missing dependencies
test -f $(shell go env GOPATH)/bin/golangci-lint || GOFLAGS="" go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
test -f $(shell go env GOPATH)/bin/golangci-lint || GOFLAGS="" go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use $(GOBIN) for the golangci-lint existence check.

Line 431 checks only GOPATH/bin; when GOBIN is set, this can cause redundant installs on every make prereqs.

Suggested fix
-	test -f $(shell go env GOPATH)/bin/golangci-lint || GOFLAGS="" go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
+	test -f $(GOBIN)/golangci-lint || GOFLAGS="" go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` at line 431, The Makefile currently checks for golangci-lint only
under $(shell go env GOPATH)/bin causing installs when GOBIN is set; update the
existence check to use $(or $(GOBIN),$(shell go env GOPATH)/bin)/golangci-lint
(or equivalent shell logic) so it prefers $(GOBIN) when present, then fallbacks
to GOPATH/bin, and keep the install command using ${GOLANGCI_LINT_VERSION}
unchanged; specifically modify the test command that references $(shell go env
GOPATH)/bin/golangci-lint to use the computed bin dir via $(or $(GOBIN),$(shell
go env GOPATH)/bin)/golangci-lint.

- Update GOLANGCI_LINT_VERSION from v1.54.2 to v2.12.2
- Update module path to use /v2/ prefix
- Add .golangci.yml with version: "2" declaration for v2 compatibility

Tracking: redhat-best-practices-for-k8s/telco-bot#49
@sebrandon1 sebrandon1 changed the title CNF-23398: Upgrade golangci-lint from v1.54.2 to v2.11.4 CNF-23398: Upgrade golangci-lint from v1.54.2 to v2.12.2 May 20, 2026
@sebrandon1 sebrandon1 force-pushed the golangci-lint-v2-upgrade branch from 59b0c3e to f6caa4a Compare May 20, 2026 22:18
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 21, 2026

@sebrandon1: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants