fix: resolve go vet sync.Mutex copy-by-value errors - #2169
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Norway-02 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 |
|
Welcome @Norway-02! It looks like this is your first PR to Project-HAMi/HAMi 🎉 |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe change updates three ChangesDevice replica updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Norway-02 <anshulkhetade02@gmail.com>
956d45d to
cecd3aa
Compare
|
cc @FouoF @archlitchi Please review this PR when you have a moment. Thank you! |
| replicatedDevice.Replicas = r.Replicas | ||
| devices.insert(name, &replicatedDevice) | ||
| orig := oDevices[r.Name][id] | ||
| replicatedDevice := &Device{ |
There was a problem hiding this comment.
hand listing fields means a new field on Device or on kubelets v1beta1.Device silently stops reaching replicas. did u look at proto.Clone for the embedded part?
Signed-off-by: Norway-02 <anshulkhetade02@gmail.com>
ba006e0 to
a01f782
Compare
|
Thank you for the feedback! I've pushed a follow-up that addresses both points. I replaced the manual Protobuf field copy with I also expanded I've run |
proto.Merge on a fresh zero-value proto works, but proto.Clone is more explicit — it returns a complete deep copy of the embedded kubelet Device in a single call, making the intent clear and removing the two-step initialize-then-merge pattern. Signed-off-by: Norway-02 <anshulkhetade02@gmail.com>
|
@mesutoezdil @archlitchi @wawa0210 PTAL when you have a chance — the last round of feedback (use |
|
Closing: after 3 commits the core go vet error in device_map.go still fails (the proto.Clone dereference still copies the embedded sync.Mutex), and real CI (Compile/Unit test/lint) has never run on this branch. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This PR resolves several
go vetviolations where async.Mutexwas inadvertently copied by value.In
devices.go, passingDeviceby value in receiver methods triggered a lock copy of the embedded protobufMessageStatemutex. I've updated these to use pointer receivers.In
device_map.go,updateDeviceMapWithReplicaswas dereferencing the device struct to create a replica. I replaced this with an explicit struct initialization that safely copies fields without copying the embedded mutex.In
server_test.go, the loop assignedtc := testCases[i]. BecauseexpectedResponseis aContainerAllocateResponsecontaining a protobuf mutex, this triggeredgo vet. I changed this to a pointer referencetc := &testCases[i].These changes ensure
go vet ./...passes cleanly on master.Which issue(s) this PR fixes:
NONE
Special notes for your reviewer:
Note: This PR was prepared with AI assistance; the solution was reviewed and tested manually.
Does this PR introduce a user-facing change?:
Summary by CodeRabbit