Skip to content

Migrate devicemanager to context logging (1/5) #132540

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

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

Conversation

chuangw6
Copy link

@chuangw6 chuangw6 commented Jun 25, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

migrate pkg/kubelet/cm/devicemanager to contextual logging

Which issue(s) this PR is related to:

#130069

Special notes for your reviewer:

This PR migrated:

  • pkg/kubelet/cm/devicemanager/plugin/v1beta1/client.go
  • pkg/kubelet/cm/devicemanager/plugin/v1beta1/handler.go
  • pkg/kubelet/cm/devicemanager/plugin/v1beta1/server.go
  • NewManagerImpl, Start and Stop in pkg/kubelet/cm/devicemanager/manager.go

Sorry for this PR's size. I fall down the rabbit hole of plumbing through context :<. I will migrate following files with smaller PRs:

  • pkg/kubelet/cm/devicemanager/manager.go
  • pkg/kubelet/cm/devicemanager/pod_devices.go
  • pkg/kubelet/cm/devicemanager/topology_hints.go
  • pkg/kubelet/cm/devicemanager/plugin/v1beta1/stub.go

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 25, 2025
Copy link

linux-foundation-easycla bot commented Jun 25, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: chuangw6 / name: Chuang Wang (40c6a0a)

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jun 25, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @chuangw6!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 25, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @chuangw6. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 needs-priority Indicates a PR lacks a `priority/foo` label and requires one. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 25, 2025
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. labels Jun 25, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 25, 2025
@yujuhong
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 25, 2025
@k8s-ci-robot k8s-ci-robot added the wg/device-management Categorizes an issue or PR as relevant to WG Device Management. label Jun 25, 2025
@chuangw6 chuangw6 force-pushed the ctx-log branch 2 times, most recently from 2986644 to 36d6bfa Compare June 25, 2025 23:33
@k8s-ci-robot k8s-ci-robot added the do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. label Jun 26, 2025
@chuangw6 chuangw6 closed this Jun 26, 2025
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. labels Jun 26, 2025
@chuangw6 chuangw6 reopened this Jun 26, 2025
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 26, 2025
@chuangw6
Copy link
Author

/retest

@chuangw6 chuangw6 force-pushed the ctx-log branch 4 times, most recently from 4eea21f to b32e789 Compare June 27, 2025 01:37
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: chuangw6
Once this PR has been reviewed and has the lgtm label, please assign random-liu, saad-ali for approval. For more information see the 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

Copy link
Contributor

@ffromani ffromani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR! I'm generally very supportive of moving to contextual logging (and my own effort starved). I expect a somehow long tail of tuning and refinements after the initial plumbing lands, but by all means let's get the plumbing merged before!
Some comments inside

Comment on lines +42 to +44
Connect(ctx context.Context) error
Run(ctx context.Context)
Disconnect(ctx context.Context) error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we can just the method signature of the interface, will check

func (h *RegistrationHandler) ValidatePlugin(pluginName string, endpoint string, versions []string) error {
klog.Info(log("Trying to validate a new CSI Driver with name: %s endpoint: %s versions: %s",
pluginName, endpoint, strings.Join(versions, ",")))
func (h *RegistrationHandler) ValidatePlugin(ctx context.Context, pluginName string, endpoint string, versions []string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise, are updating all plugins in one go or just device manager?

Copy link
Author

@chuangw6 chuangw6 Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My goal was to just update device manager, but to migrate pkg/kubelet/cm/devicemanager/plugin/v1beta1/handler.go, the PluginHandler interface in pkg/kubelet/pluginmanager/cache/types.go needs to be updated. Otherwise, type check will fail. This led to a series of cascading changes.

@chuangw6 chuangw6 changed the title (WIP) Migrate devicemanager to context logging (1/5) Migrate devicemanager to context logging (1/5) Jun 30, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 30, 2025
@chuangw6 chuangw6 requested review from tallclair and ffromani June 30, 2025 21:28
@chuangw6
Copy link
Author

nolint:errcheck

@chuangw6
Copy link
Author

/test pull-kubernetes-linter-hints

@chuangw6
Copy link
Author

/test pull-kubernetes-node-e2e-containerd

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jun 30, 2025

@chuangw6: 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-linter-hints 40c6a0a link false /test pull-kubernetes-linter-hints

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.

@ffromani
Copy link
Contributor

ffromani commented Jul 1, 2025

General note about migration to contextual logging. There are quite few areas where we can use or should use more contexts; that's fine. In general however just passing context around for the sake of using the logger instance (because this is only the legit use of the context in such cases) seems suboptimal.
Plus, we don't use WithName or WithValues a lot, which is the real place where the contextual logging really adds value.
In this case it seems awkward to me to do the FromContext/NewContext dance when we can "just" pass around the logger instance.
I guess we can do a sweeping change in general and then refine in the later versions once we gain more confidence and we learn better the usages of the logger.
TL;DR: I'm ok doing the change in waves (sweeping waves), this will be the first of quite a few.

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. 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. wg/device-management Categorizes an issue or PR as relevant to WG Device Management.
Development

Successfully merging this pull request may close these issues.

6 participants