fix: unbreak go vet and make build on master - #940
Conversation
The csi spec bump in openkruise#876 (v1.9.0 to v1.13.0) gave csi.NodePublishVolumeRequest a protoimpl.MessageState, which embeds a sync.Mutex. The storage-cli passes that struct by value throughout, so go vet started reporting 18 copylocks findings and exiting 1. Makefile declares vet as a prerequisite of both build and test-e2e, so neither ran. Take the request by pointer instead, which is the normal way to handle a protobuf message and removes a real struct copy from the mount path. make build still produced no binary after that, for a second and unrelated reason: the target compiled a single file rather than the package, so executeCABindings in ca_binding.go was invisible to it. Build the package, matching what the okactl target two lines below already does. go vet ./... is now clean and make build produces bin/agent-sandbox-controller. Fixes openkruise#905 Signed-off-by: Om <omlahore47@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #940 +/- ##
==========================================
- Coverage 83.08% 83.07% -0.01%
==========================================
Files 259 259
Lines 22555 22555
==========================================
- Hits 18739 18738 -1
- Misses 3093 3095 +2
+ Partials 723 722 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #905
Two separate things stop
make buildproducing a binary on a clean checkout of master. The issue diagnosed the first; the second only becomes visible once the first is fixed.1. go vet fails, and vet gates the build
#876 bumped
container-storage-interface/specfrom v1.9.0 to v1.13.0. In v1.13.0csi.NodePublishVolumeRequestcarries aprotoimpl.MessageState, which embeds async.Mutex. The storage CLI passes that struct by value everywhere, so vet now reports 18 copylocks findings and exits 1:Makefile:81andMakefile:110both declarevetas a prerequisite, sobuildandtest-e2estop before doing anything.Fixed by taking
*csi.NodePublishVolumeRequestthrough theProviderinterface,RunNodePublishVolumeandvalidateGeneralParams. That is the ordinary way to handle a generated protobuf message, and it removes a real struct copy from the mount path rather than just silencing the check.main.goalready didproto.Unmarshal(configRaw, &csiReq), so it had the pointer in hand anyway.No production
Providerimplementations exist outside the test fakes, so the interface change is contained.2. The build target compiles a file, not a package
With vet clean,
make buildgets further and then fails:executeCABindingslives incmd/agent-sandbox-controller/ca_binding.go, same package. The target was:Naming a single
.gofile builds only that file, so its siblings are invisible.go build ./cmd/agent-sandbox-controller/has always worked, which is why this never showed up ingo build ./...or in CI.Changed to build the package. The
build-okactltarget two lines below already uses./cmd/okactl, so this makes the two consistent.Verification
go test ./pkg/agent-runtime/storage-cli/...passes across all four packages.37 insertions, 39 deletions. Most of it is the mechanical
csi.NodePublishVolumeRequestto*csi.NodePublishVolumeRequestchange in the test fakes.One note on scope
make buildrunsgo fmt ./..., which reformatted four unrelated test files on my machine (pkg/identity/ca_cert_injector_test.goand three others, all struct-field alignment). I reverted those rather than fold unrelated churn in here, but they are unformatted on master and something will keep re-flagging them. Worth a separate cleanup.Why CI missed it
No workflow runs
go vet. Theundefined: executeCABindingscase is worse, since it only appears inmake buildand never ingo build ./.... A CI job that runsmake buildwould catch both.