Skip to content

Migrate Kubelet codebase to contextual logging #130069

Open
@bart0sh

Description

@bart0sh

What would you like to to?

Support contextual logging in Kubelet.

Why is this needed?

To implement https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/3077-contextual-logging

How to do it?

General instructions can be found here: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md

The approach I'd like to propose for Kubelet is to do it directory by directory, making as little changes as possible to other components. If the first level directory requires a lot of changes, consider migrating its subdirectories in a separate PRs, e.g. instead of migrating pkg/kubelet/cm at once, consider migrating pkg/kubelet/cm/cpumanager, pkg/kubelet/cm/containermap, etc.

Use context.TODO() to create context that should be passed as an argument in future to avoid massive changes in other components. Add a comment explaining that this is a temporary solution and when it needs to be replaced by the direct context usage.

Look at the existing context.TODO() and context.Background() calls in the directory. Replace them by the ctx usage if possible. Replace context.Background() with context.TODO() if ctx is not yet accessible there.

After all source files in the directory are migrated, add the directory path to the ./hack/logcheck.conf and run hack/update-golangci-lint-config.sh to generate hack/golangci*.yaml configs. This will prevent usage of non-contextual logging for the directory.

Last step of this migration is to migrate pkg/kubelet/*.go, add pkg/kubelet to the ./hack/logcheck.conf, remove all its subdirectories from there and regenerate golangci configs.

Which components are already migrated and which still need to be migrated?

Metadata

Metadata

Assignees

Labels

area/logginghelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.priority/important-longtermImportant over the long term, but may not be staffed and/or may need multiple releases to complete.sig/instrumentationCategorizes an issue or PR as relevant to SIG Instrumentation.sig/nodeCategorizes an issue or PR as relevant to SIG Node.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions