-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Run govulncheck with project gotoolchain #20636
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
base: main
Are you sure you want to change the base?
Run govulncheck with project gotoolchain #20636
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ivanvc The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
7adc798
to
b02eb2c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted filessee 142 files with indirect coverage changes @@ Coverage Diff @@
## main #20636 +/- ##
==========================================
- Coverage 69.02% 62.04% -6.99%
==========================================
Files 420 406 -14
Lines 34783 33661 -1122
==========================================
- Hits 24008 20884 -3124
- Misses 9373 11216 +1843
- Partials 1402 1561 +159 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
/retest |
This is the prow job run for the new approach: https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/etcd-io_etcd/20636/pull-etcd-govulncheck/1965200268417044480 |
We already set the environment variable
I recall that the golang team recommends to use the latest |
It's still a problem without this pull request. Maybe I wasn't clear in my description. Let me try to make this clear. The problem is that currently installing Lines 196 to 199 in ab98b5b
At this point, This is the reason why we needed to introduce different Prow jobs in kubernetes/test-infra#35050, as the release branches were using Go 1.23, while Prow has Go 1.24. So, to fix this issue, we need to ensure that when we install In this pull request, I'm moving the installation from the In conclusion, it's still a problem without this pull request.
This comes from the installation instructions on https://pkg.go.dev/golang.org/x/vuln#section-readme. I didn't think it would harm pointing to a specific govulncheck version, as it still uses the external database. But I can revert this part. |
b02eb2c
to
4470ecb
Compare
Noting that this is a blocker to update the main branch to Go 1.25. |
4470ecb
to
b1a881e
Compare
/retest |
This makes sense. But I don't need to manage |
tools/mod/go.mod
Outdated
@@ -17,6 +17,7 @@ require ( | |||
go.etcd.io/gofail v0.2.0 | |||
go.etcd.io/protodoc v0.0.0-20180829002748-484ab544e116 | |||
go.etcd.io/raft/v3 v3.6.0 | |||
golang.org/x/vuln v1.1.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to add this. Is there any problem to use the latest govulncheck version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without adding it to tools/mod
, we can't use go_run_tool
, as I get the error:
% (cd api && 'go' 'install' 'golang.org/x/vuln/cmd/govulncheck@latest')
cannot find module providing package golang.org/x/vuln/cmd/govulncheck: import lookup disabled by -mod=readonly
Failed to install tool 'golang.org/x/vuln/cmd/govulncheck@latest'
There was a Failure in module api, aborting...
FAIL: 'govuln' FAILED at Wed Sep 10 01:53:37 PM PDT 2025
Thinking of using Go 1.24's tool directive won't work in the future if we want to point to "latest", because the tool directive adds an indirect dependency.
tools/mod/tools.go
Outdated
@@ -31,6 +31,7 @@ import ( | |||
_ "github.com/google/yamlfmt/cmd/yamlfmt" | |||
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway" | |||
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2" | |||
_ "golang.org/x/vuln/cmd/govulncheck" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this.
That sounds great, I'll drop that commit. |
b1a881e
to
6a7dd21
Compare
Ensure that GOTOOLCHAIN is set by the time it runs, to ensure the binary gets compiled with the right Go version. Signed-off-by: Ivan Valdes <[email protected]>
6a7dd21
to
26a9faa
Compare
/retest |
# Install govulncheck without using the tools/mod module, or run_go_tool, | ||
# as the installation instructions point to latest. Doing it with run_go_tool, | ||
# or even with Go 1.24's tool directive, will add the dependency (direct or | ||
# indirect) to the tools/mod Go module. | ||
run go install golang.org/x/vuln/cmd/govulncheck@latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good, but the comment is a little confusing. go install
will never update the dependencies (go.mod file).
For simplicity, let's just add a comment for run_go_tool something like This function is only used to run commands which are managed by tools/mod
?
Move to the script executing and installing
govulncheck
. This way, the installed version matches theGOTOOLCHAIN
defined inscripts/test_lib.sh
. The current issue is that the Prow infrastructure is still using Go 1.24; there's a version mismatch if we don't specifyGOTOOLCHAIN
. With this, we no longer need the multi-image hack removed in kubernetes/test-infra#35363, introduced in kubernetes/test-infra#35050.As reference, this is the failure before using
GOTOOLCHAIN
(from #20635): https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/etcd-io_etcd/20635/pull-etcd-govulncheck/1965163337700347904Now, after pushing these two commits in that branch, the result is a successful run: https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/etcd-io_etcd/20635/pull-etcd-govulncheck/1965196061718876160
Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.