Skip to content
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

WIP: node: cm: use maps.Clone instead of reinvent it #128679

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ffromani
Copy link
Contributor

@ffromani ffromani commented Nov 7, 2024

/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 and slices package we can use instead of reinventing in our codebase

Which issue(s) this PR fixes:

Fixes N/A

Special notes for your reviewer:

N/A

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 7, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Nov 7, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ffromani
Once this PR has been reviewed and has the lgtm label, please assign klueska for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ffromani
Copy link
Contributor Author

ffromani commented Nov 7, 2024

WIP because I'd like to lookup for more instances and clean them up

@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 7, 2024
@SergeyKanzhelev
Copy link
Member

WIP because I'd like to lookup for more instances and clean them up

sure. Ping when ready.

@@ -36,11 +37,7 @@ func NewContainerMap() ContainerMap {

// Clone creates a deep copy of the ContainerMap
func (cm ContainerMap) Clone() ContainerMap {
Copy link
Contributor

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

Copy link
Contributor Author

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 remembered ContainerMap is more than such a thin wrapper. I confused it with pod_devices)

I'm open to conversation here.

@ffromani
Copy link
Contributor Author

/retest

@k8s-ci-robot
Copy link
Contributor

@ffromani: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-e2e-gce 12fc5d2 link true /test pull-kubernetes-e2e-gce

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
Status: not-only-sig-node
Development

Successfully merging this pull request may close these issues.

4 participants