Skip to content

chore(kubelet): migrate config to contextual logging #130581

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

zhifei92
Copy link
Contributor

@zhifei92 zhifei92 commented Mar 5, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

migrate kubelet/config to contextual logging

Which issue(s) this PR fixes:

Fixes #
part of #130069

Special notes for your reviewer:

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. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 5, 2025
@k8s-ci-robot k8s-ci-robot requested review from ffromani and sttts March 5, 2025 08:56
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. labels Mar 5, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Mar 5, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zhifei92
Once this PR has been reviewed and has the lgtm label, please assign dchen1107 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

@zhifei92
Copy link
Contributor Author

zhifei92 commented Mar 5, 2025

/cc @bart0sh

@k8s-ci-robot k8s-ci-robot requested a review from bart0sh March 5, 2025 08:57
@zhifei92 zhifei92 force-pushed the migrate-kubelet-config-to-contextual-logging branch from e749fb1 to 24b2024 Compare March 6, 2025 12:00
@bart0sh
Copy link
Contributor

bart0sh commented Mar 7, 2025

/assign
/triage accepted
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 7, 2025
@bart0sh bart0sh moved this from Triage to Needs Reviewer in SIG Node: code and documentation PRs Mar 7, 2025
@@ -99,9 +99,12 @@ func (c *PodConfig) SeenAllSources(seenSources sets.Set[string]) bool {
if c.pods == nil {
return false
}
// Use klog.TODO() because we currently do not have a proper context to pass in.
// Replace this with an appropriate logger when refactoring this function to accept a logger parameter.
logger := klog.TODO()
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this one require many changes in other components? If not, please consider passing context to this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it involves more than 10 modifications, but most of them are in test files. What would be a good approach in this situation?

pkg/kubelet/kubelet.go:         sourcesReady:                   config.NewSourcesReady(kubeDeps.PodConfig.SeenAllSources),
pkg/kubelet/volumemanager/volume_manager_test.go:                       sourcesReady := config.NewSourcesReady(func(_ sets.Set[string]) bool { return true })
pkg/kubelet/volumemanager/volume_manager_test.go:       sourcesReady := config.NewSourcesReady(func(_ sets.Set[string]) bool { return true })
pkg/kubelet/volumemanager/volume_manager_test.go:       sourcesReady := config.NewSourcesReady(func(_ sets.Set[string]) bool { return true })
pkg/kubelet/volumemanager/volume_manager_test.go:               sourcesReady := config.NewSourcesReady(func(_ sets.Set[string]) bool { return true })
pkg/kubelet/volumemanager/volume_manager_test.go:                       sourcesReady := config.NewSourcesReady(func(_ sets.Set[string]) bool { return true })
pkg/kubelet/config/sources.go:// NewSourcesReady returns a SourcesReady with the specified function.
pkg/kubelet/config/sources.go:func NewSourcesReady(sourcesReadyFn SourcesReadyFn) SourcesReady {
pkg/kubelet/kubelet_test.go:    kubelet.sourcesReady = config.NewSourcesReady(func(_ sets.Set[string]) bool { return true })
pkg/kubelet/kubelet_test.go:    kubelet.sourcesReady = config.NewSourcesReady(func(_ sets.Set[string]) bool { return ready })
pkg/kubelet/pluginmanager/plugin_manager_test.go:               sourcesReady := config.NewSourcesReady(func(_ sets.Set[string]) bool { return true })
pkg/kubelet/cm/devicemanager/manager_test.go:   sourcesReady := config.NewSourcesReady(func(_ sets.Set[string]) bool { return true })

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it would be a good approach. Please proceed with the changes, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, sourcesReadyFn is called by AllReady(), and modifying AllReady() would involve significant changes.

// AllReady returns true if each configured source is ready.
func (s *sourcesImpl) AllReady() bool {
	s.lock.RLock()
	defer s.lock.RUnlock()
	return s.sourcesReadyFn(s.sourcesSeen)
}

call AllReady()

-> % grep -rE ".AllReady()" pkg/kubelet     
pkg/kubelet/kubelet.go: if !kl.sourcesReady.AllReady() {
pkg/kubelet/kubelet.go:         if !kl.sourcesReady.AllReady() {
pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:                done := sourcesReady.AllReady()
pkg/kubelet/config/sources.go:  // AllReady returns true if the currently configured sources have all been seen.
pkg/kubelet/config/sources.go:  AllReady() bool
pkg/kubelet/config/sources.go:// AllReady returns true if each configured source is ready.
pkg/kubelet/config/sources.go:func (s *sourcesImpl) AllReady() bool {
pkg/kubelet/container/container_gc.go:  // AllReady returns true if the currently configured sources have all been seen.
pkg/kubelet/container/container_gc.go:  AllReady() bool
pkg/kubelet/container/container_gc.go:  return cgc.runtime.GarbageCollect(ctx, cgc.policy, cgc.sourcesReadyProvider.AllReady(), false)
pkg/kubelet/container/container_gc.go:  return cgc.runtime.GarbageCollect(ctx, cgc.policy, cgc.sourcesReadyProvider.AllReady(), true)
pkg/kubelet/container/testing/fake_ready_provider.go:// AllReady notifies caller that the Fake Provider is ready.
pkg/kubelet/container/testing/fake_ready_provider.go:func (frp *FakeReadyProvider) AllReady() bool {
pkg/kubelet/cm/cpumanager/cpu_manager.go:func (s *sourcesReadyStub) AllReady() bool          { return true }
pkg/kubelet/cm/cpumanager/cpu_manager.go:       if !m.sourcesReady.AllReady() {
pkg/kubelet/cm/devicemanager/manager.go:func (s *sourcesReadyStub) AllReady() bool          { return true }
pkg/kubelet/cm/devicemanager/manager.go:        if !m.sourcesReady.AllReady() {
pkg/kubelet/cm/devicemanager/manager.go:        if !m.sourcesReady.AllReady() && m.isContainerAlreadyRunning(podUID, contName) {
pkg/kubelet/cm/memorymanager/memory_manager.go:func (s *sourcesReadyStub) AllReady() bool          { return true }
pkg/kubelet/cm/memorymanager/memory_manager.go: if !m.sourcesReady.AllReady() {
pkg/kubelet/cm/dra/manager.go:  if m.sourcesReady == nil || !m.sourcesReady.AllReady() {


Copy link
Contributor

Choose a reason for hiding this comment

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

OK, let's not do that. At least we tried :)

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 8, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 4ac9eda31139bf26c37b2408fb39c6d96d477783

@bart0sh bart0sh moved this from Needs Reviewer to Needs Approver in SIG Node: code and documentation PRs Mar 8, 2025
@bart0sh
Copy link
Contributor

bart0sh commented Mar 8, 2025

/assign @mrunalp @SergeyKanzhelev
for approval

@zhifei92
Copy link
Contributor Author

/cc @bart0sh

@k8s-ci-robot k8s-ci-robot requested a review from bart0sh March 18, 2025 05:57
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 3, 2025
@zhifei92 zhifei92 force-pushed the migrate-kubelet-config-to-contextual-logging branch from 24b2024 to e95c53b Compare May 13, 2025 02:34
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 13, 2025
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 13, 2025
@k8s-ci-robot
Copy link
Contributor

@zhifei92: 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-unit-windows-master e95c53b link false /test pull-kubernetes-unit-windows-master

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.

@SergeyKanzhelev SergeyKanzhelev moved this from Needs Approver to Needs Reviewer in SIG Node: code and documentation PRs May 31, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 26, 2025
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-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

5 participants