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

k8s.io/kms: drop direct dependency on klog #120947

Merged
merged 1 commit into from
Oct 18, 2023

Conversation

enj
Copy link
Member

@enj enj commented Sep 29, 2023

Signed-off-by: Monis Khan mok@microsoft.com

Builds on #120896

This will make #120225 drop klog altogether.

/kind cleanup
/assign aramase

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. 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. area/release-eng Issues or PRs related to the Release Engineering subproject area/test sig/auth Categorizes an issue or PR as relevant to SIG Auth. triage/accepted Indicates an issue or PR is ready to be actively worked on. sig/release Categorizes an issue or PR as relevant to SIG Release. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed 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 Sep 29, 2023
Copy link
Member

@aramase aramase left a comment

Choose a reason for hiding this comment

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

/lgtm

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

LGTM label has been added.

Git tree hash: f881f8443265e26c1ce9c5578278b1c335cd9077

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 29, 2023
Copy link
Member

@aramase aramase left a comment

Choose a reason for hiding this comment

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

/lgtm

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

LGTM label has been added.

Git tree hash: 76dafbdf43303b1704ffbfa1227c63420b099b3b

@dims
Copy link
Member

dims commented Sep 29, 2023

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 29, 2023
@dims
Copy link
Member

dims commented Sep 29, 2023

/assign @pohly

@enj @aramase we don't yet have guidance from folks working on logging/klog about allowing slog in our code base

@dims
Copy link
Member

dims commented Sep 29, 2023

also build failure:

vendor/k8s.io/kms/pkg/service/grpc_service.go:21:2: package log/slog is not in GOROOT (/usr/local/go/src/log/slog)

@enj
Copy link
Member Author

enj commented Sep 29, 2023

/assign @pohly

@enj @aramase we don't yet have guidance from folks working on logging/klog about allowing slog in our code base

FWIW the kms staging repo is for external consumption, hence I was trying to limit its dep tree.

also build failure:

vendor/k8s.io/kms/pkg/service/grpc_service.go:21:2: package log/slog is not in GOROOT (/usr/local/go/src/log/slog)

I figured it would fail if we didn't support go1.21 yet :)

@pohly
Copy link
Contributor

pohly commented Sep 30, 2023

Using slog.Debug means that logging will use the global default slog handler. That's okay(is), that handler can be set by a binary such that the output goes to klog, if that is what the binary is using. See:

However, it means that the code doesn't support contextual logging. My proposal is that we continue to use klog for handling access to a logger and the go-logr API for log calls, i.e. not switch to slog:

How important is it to remove the klog dependency? This is doable, but requires more changes than planned right now. For example, there are helpers in klog like klog.KObj which are needed for structured logging. We would need a separate package with all the calls that we intend to keep using.

@pohly
Copy link
Contributor

pohly commented Sep 30, 2023

For the sake of simplicity, that other package could be klog/v3... then all it takes in code with full conversion to structured, contextual logging would be a s;klog/v2;klog/v3. But a bit more thought will be needed regarding interoperability of the two versions...

@enj
Copy link
Member Author

enj commented Sep 30, 2023

How important is it to remove the klog dependency?

Quite high for the kms staging repo because the code in there has no use in k/k itself, it is just a thin wrapper around the proto APIs to make it easy for someone to build a plugin. The reason for using slog is so that a plugin can easily override the logger and doesn't have to deal with any of the weirdness associated with klog. I can certainly make this code just use the log package instead if we really want to. Alternatively I can delete the log statements here and move them into the mock implementation.

@enj
Copy link
Member Author

enj commented Sep 30, 2023

Note also that this code doesn't need contextual logging because it is never going to be used in-tree. Basically this change should have no bearing on what we decide to do as a whole for the Kube project (where I agree using klog is the correct choice).

@pohly
Copy link
Contributor

pohly commented Oct 1, 2023

If you want to get rid of klog, then I'd prefer to have no log calls in that package at all. That's the only short-term solution anyway, or are you ready to make Go 1.21 the required version for it?

@pohly
Copy link
Contributor

pohly commented Oct 1, 2023

Note also that this code doesn't need contextual logging because it is never going to be used in-tree.

Who says that contextual logging is only something that is done in-tree? 😄

The concept also applies out-of-tree. For example, Cluster API is using it and the controller-runtime has support for it.

@enj enj changed the title k8s.io/kms: drop direct dependency on klog via go1.21 slog k8s.io/kms: drop direct dependency on klog Oct 18, 2023
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 18, 2023
@enj
Copy link
Member Author

enj commented Oct 18, 2023

/hold cancel

I removed all usage of slog from this PR.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 18, 2023
Signed-off-by: Monis Khan <mok@microsoft.com>
Copy link
Member

@aramase aramase left a comment

Choose a reason for hiding this comment

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

/lgtm

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

LGTM label has been added.

Git tree hash: 35a7cd8278402fa8e92a72fdf841aa58914e871e

@k8s-ci-robot k8s-ci-robot merged commit bd07d56 into kubernetes:master Oct 18, 2023
15 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/release-eng Issues or PRs related to the Release Engineering subproject area/test 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. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/release Categorizes an issue or PR as relevant to SIG Release. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants