-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
✨ Use klog
as kubebuilder default logger
#3033
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: astraw99 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 |
Hi @astraw99. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
3c2e265
to
e997453
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @astraw99,
Thank you for your contribution 🥇.
Would not the change done in controller-runtime kubernetes-sigs/controller-runtime#2029 also address your motivation?
(ihmo) we need to discuss if we would like to change the default log lib to klog. For that, we need to understand what are the motivations for the controller-runtime use of zap first. Would possible for you to open an issue with the proposed idea and check out it and add the pros and cons that you see to do this change?
An alternative option would to be add a FAQ section in the docs describing to users how they can customize the scaffold to use klog instead.
/ok-to-test |
@@ -196,7 +198,6 @@ import ( | |||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | |||
clientgoscheme "k8s.io/client-go/kubernetes/scheme" | |||
ctrl "sigs.k8s.io/controller-runtime" | |||
"sigs.k8s.io/controller-runtime/pkg/log/zap" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alvaroaleman @joelanford do you remember why we implement the log zap feature in controller-runtime instead of using klog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/hold
Only to avoid it getting merged before it has enough reviews and discussions.
@@ -8,6 +8,7 @@ require ( | |||
k8s.io/api v0.25.0 | |||
k8s.io/apimachinery v0.25.0 | |||
k8s.io/client-go v0.25.0 | |||
k8s.io/klog/v2 v2.70.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cons: It will add a new dep for the projects which increases the cost for maintainability.
Opened a proposal #3036, including log format comparison and pros/cons. |
klog
as kubebuilder default loggerklog
as kubebuilder default logger
After the issue discussion, we prefer to use zap as default logger. |
Fixes #3036
Fixes kubernetes-sigs/controller-runtime#2024
To make the log output consistent with K8s core components (kube-apiserver, kube-controller-manager, etc), and
more human readable.
Test results:
Before this PR, the kubebuilder generated controller-manager log is:
After this PR, the kubebuilder generated controller-manager log is: