-
Notifications
You must be signed in to change notification settings - Fork 16
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
structured-logging: enable KobjSlice usage and warn Kobjs usage #1
structured-logging: enable KobjSlice usage and warn Kobjs usage #1
Conversation
Welcome @harshanarayana! |
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.
I think we need also a test case where KObjs
is flagged as a function that shouldn't be used.
@pohly Sorry, I have been away for a few days. I will take a look at this and get the update published this week |
10e7f93
to
95c3097
Compare
@pohly PTAL. I've added the required test as suggested |
/cc @thockin |
95c3097
to
76fb3f2
Compare
@@ -29,4 +29,5 @@ func doNotAlllowKlog() { | |||
klog.InfoS("test log") // want `function "InfoS" should not be used, convert to contextual logging` | |||
klog.ErrorS(nil, "test log") // want `function "ErrorS" should not be used, convert to contextual logging` | |||
klog.V(1).Infof("test log") // want `function "V" should not be used, convert to contextual logging` `function "Infof" should not be used, convert to contextual logging` | |||
klog.KObjs(nil) // want `function "KObjs" should not be used, convert to contextual logging` |
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.
I think we want a better warning here. "convert to contextual logging" is misleading when printed for a line which uses contextual logging.
This implies that we need separate code for it and cannot simply add it to the blacklisted functions.
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.
At that point it probably needs a separate flag for enabling the check.
I'm leaning towards enabling it by default, even if that means that we need to update code in Kubernetes before we can switch to the newer logtools, or disable the check initially in Kubernetes' logcheck.conf.
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.
I am fine with it. Do you have any preferences on how you would like this to look like @pohly ?
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.
No, not really.
76fb3f2
to
3a1631d
Compare
@pohly PTAL when time Permits. I've added a few flag for the deprecation check and is enabled by default right now. |
3a1631d
to
6e0d37e
Compare
6e0d37e
to
32f29ca
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.
The code looks good now, but I remembered that https://github.com/kubernetes-sigs/logtools/blob/main/logcheck/README.md has documentation for the available checks - can you add the new one there?
32f29ca
to
f2a2dfa
Compare
@pohly Updated the README. It was also missing the |
Keeping documentation up-to-date... always easy to forget. Everyone should just read the source code! 😅 Thanks for updating everything. |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: harshanarayana, pohly The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This pull request enables detection and warning on now deprecated
KObjs
. It is suggested to use theKObjSlice
instead of usingKobjs
for better logging performance Since kubernetes/kubernetes#110724 is now merged, We can reap the benefits of the change that went into theklog
via kubernetes/klog#322Fixes Part of kubernetes/kubernetes#110737