feat: add DeepCopy function for DeviceUsage and its nested types#1818
Conversation
Signed-off-by: Shouren Yang <yangshouren@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request implements DeepCopy methods for various structures across the pkg/device, pkg/scheduler, and pkg/scheduler/policy packages to ensure proper object duplication and isolation. Comprehensive unit tests have been added to verify that mutations to the copied objects do not affect the originals. I have identified a potential issue where the DeepCopy implementation for CustomInfo (a map[string]any) performs a shallow copy of the map values; if these values contain reference types, they will remain shared between the original and the copy. I recommend either implementing a more robust deep copy mechanism for these maps or explicitly documenting this limitation.
… field Signed-off-by: Shouren Yang <yangshouren@gmail.com>
eacc7b8 to
f340bc4
Compare
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: archlitchi, Shouren The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…ject-HAMi#1818) * feat: add DeepCopy function for DeviceUsage and its nested types Signed-off-by: Shouren Yang <yangshouren@gmail.com> * fix: issue from golangci-lint about formatted, maps.Copy and embedded field Signed-off-by: Shouren Yang <yangshouren@gmail.com> --------- Signed-off-by: Shouren Yang <yangshouren@gmail.com>
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR add the DeepCopy function for DeviceUsage and its nested types. So we can deepcopy them directly instead of using JSON serialization (e.g. in #1773)
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
AI Assistance Notice:
Kimi Code CLI helps me generating the test code