Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v1.14] golangci: Enable errorlint #31793

Merged
merged 3 commits into from
Apr 17, 2024
Merged

[v1.14] golangci: Enable errorlint #31793

merged 3 commits into from
Apr 17, 2024

Conversation

jrajahalme
Copy link
Member

@jrajahalme jrajahalme commented Apr 5, 2024

Note: Added commit updating golangci-lint version used by make lint to match that of the GH Go lint action.

Once this PR is merged, a GitHub action will update the labels of these PRs:

 31458

@jrajahalme jrajahalme added kind/backports This PR provides functionality previously merged into master. backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. labels Apr 5, 2024
@jrajahalme jrajahalme requested review from a team as code owners April 5, 2024 10:19
@jrajahalme
Copy link
Member Author

/test-backport-1.14

@jrajahalme
Copy link
Member Author

/test-backport-1.14

Copy link
Contributor

@learnitall learnitall left a comment

Choose a reason for hiding this comment

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

Thanks!

'make lint' fails like this:

docker run --rm -v `pwd`:/app -w /app docker.io/golangci/golangci-lint:v1.53.3@sha256:1e0e2867b387bf68762427db499a963e43582b06819992db205fc31daa75ceea golangci-lint run
level=error msg="Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: errors parsing go.mod:\n/app/go.mod:4: invalid go version '1.21.0': must match format 1.23\n"
make: *** [Makefile:424: golangci-lint] Error 3

This is due to a too old Go version within the golangci-lint v1.53.3 image:

$ docker run --rm -v `pwd`:/app -w /app docker.io/golangci/golangci-lint:v1.53.3@sha256:1e0e2867b387bf68762427db499a963e43582b06819992db205fc31daa75ceea go version
go version go1.20.5 linux/arm64

Fix by using the same golangci-lint version for `make lint` as we already
use for the GH Go lint action.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
[ upstream commit d20f15e ]

Enable errorlint in golangci-lint to catch uses of improper formatters
for Go errors. This helps avoid unnecessary error/warning logs that
cause CI flakes, when benign error cases are not caught due to failing
error unwrapping when a string or value formatter has been used instead
of the dedicated `%w`.

Related: #31147
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
[ upstream commit fe46958 ]

Precede each `%w` formatter with a colon.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
@jrajahalme
Copy link
Member Author

rebased & resolved conflicts

@jrajahalme
Copy link
Member Author

/test-backport-1.14

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Apr 17, 2024
@aditighag aditighag merged commit 2572ee4 into v1.14 Apr 17, 2024
225 checks passed
@aditighag aditighag deleted the fix-error-wrapping-1.14 branch April 17, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. kind/backports This PR provides functionality previously merged into master. ready-to-merge This PR has passed all tests and received consensus from code owners to merge.
Projects
No open projects
Status: Released
Development

Successfully merging this pull request may close these issues.

None yet

5 participants