-
Notifications
You must be signed in to change notification settings - Fork 41.5k
node: cm: use maps.Clone instead of reinvent it #128679
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
node: cm: use maps.Clone instead of reinvent it #128679
Conversation
WIP because I'd like to lookup for more instances and clean them up |
sure. Ping when ready. |
} | ||
|
||
// Clone creates a deep copy of the ContainerMap | ||
func (cm ContainerMap) Clone() ContainerMap { |
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.
personally I'd drop this function entirely as it just uses a stdlib function anyway
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.
I thought about it. I'd argue that if we bothered to create a type around essentially a map, we should not break the abstraction, and if so we need the trivial Clone
method.
Other (more far-fetching?) options:
- dissolve
ContainerMap
and make use an actual map + helper functions - make
ContainerMap
more opaque, fully wrap it into a struct, to open the option in the future to add locks (spoiler: node: cm: don't share containerMap instances between managers #128657 was caused largely because I incorrectly rememberedContainerMap
is more than such a thin wrapper. I confused it withpod_devices
)
I'm open to conversation here.
/retest |
/priority backlog |
12fc5d2
to
10e987e
Compare
@haircommander / @SergeyKanzhelev ready for review |
/lgtm |
LGTM label has been added. Git tree hash: f1ae7e51b37fc764a285b87cb5d4c964deddbc12
|
/retest-required |
/triage accepted even though it's bad practice to self-triage issues, in this case it's pretty evident from the context so I'm just fixing labels post-fact |
/assign @SergeyKanzhelev |
ready and LGTM'd! |
As pointed out in kubernetes#128657 (comment) Signed-off-by: Francesco Romani <fromani@redhat.com>
10e987e
to
e766b04
Compare
rebased on top of master, no code changes |
/cc @swatisehgal |
/lgtm |
LGTM label has been added. Git tree hash: 2b3e757414f8c5c3e608d7490808437ef2e0fc38
|
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ffromani, swatisehgal 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 |
/kind cleanup
What this PR does / why we need it:
As emerged during the review of #128657 (comment) , golang stdlib now features helpers in
maps
andslices
package we can use instead of reinventing in our codebaseWhich issue(s) this PR fixes:
Fixes N/A
Special notes for your reviewer:
N/A
Does this PR introduce a user-facing change?