-
Notifications
You must be signed in to change notification settings - Fork 40.7k
Migrate pkg/kubelet/winstats to contextual logging #131001
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
base: master
Are you sure you want to change the base?
Migrate pkg/kubelet/winstats to contextual logging #131001
Conversation
Hi @Chulong-Li. Thanks for your PR. I'm waiting for a kubernetes 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-sigs/prow repository. |
/wg structured-logging |
@Chulong-Li: GitHub didn't allow me to request PR reviews from the following users: kubernetes/wg-structured-logging-reviews. Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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. |
/cc @bart0sh |
/ok-to-test |
|
||
cadvisorapi "github.com/google/cadvisor/info/v1" | ||
"github.com/stretchr/testify/assert" | ||
"k8s.io/klog/v2/ktesting" |
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.
A super nit: please group the imports by organization. We generally refer to the following convention:
Imports are organized in groups, with blank lines between them. The standard library packages are always in the first group.
ref: https://go.dev/wiki/CodeReviewComments#imports
Although the lint in the k/k repo won’t mind it :)
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.
@HirazawaUi Thanks for comments! That's a good point. Should we update it like below?
import (
"testing"
"unsafe"
cadvisorapi "github.com/google/cadvisor/info/v1"
"github.com/stretchr/testify/assert"
"k8s.io/klog/v2/ktesting"
)
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.
Yes, that's quite right.
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.
@HirazawaUi Have updated the order of imports for all related files to follow the standard convention. Could you please take another look?
@@ -25,6 +25,7 @@ import ( | ||
|
||
cadvisorapi "github.com/google/cadvisor/info/v1" | ||
"github.com/stretchr/testify/assert" | ||
"k8s.io/klog/v2/ktesting" |
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.
Same as above.
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.
Updated as well
/retest |
1 similar comment
/retest |
@Chulong-Li Thank you for the PR! It looks good to me from the first brief look. Please, update lint configurations in hacks/ thanks! |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Chulong-Li 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 |
@bart0sh Thanks for the reminder! Almost missed this part. I've just updated the lint configurations in hack folder. Please take another look. 😊 |
d7578e6
to
2667b18
Compare
Squashed the commits for simplicity |
/retest |
1 similar comment
/retest |
The failure of the |
/skip pull-kubernetes-e2e-capz-windows-master |
@@ -233,7 +234,7 @@ func convertWinApiToCadvisorApi(buffer []byte) (int, int, []cadvisorapi.Node, er | ||
} | ||
|
||
default: | ||
klog.V(4).Infof("Not using Windows CPU relationship type: %d", info.Relationship) |
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.
It's interesting that this non-structured logging was here. Theoretically it should raise lint errors as all pkg/kubelet is supposed to use structured 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.
We have a gap with linting: it doesn't run for Windows-only code like this one here. Might be worth closing?
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.
We also don't for e.g. GOOS=arm64, right?
We have some very specific linting for "does it typecheck" that targets all platforms, with a custom tool.
I'd be a bit concerned about the cost to golangci-lint for all platforms, but I suppose we're more likely to have build tagged files for linux,windows generally speaking.
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.
It's definitely gradual and a question of "bang for the buck". My expectation is that we have more Windows-only code than arm64-only code.
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 had a brief look by setting GOOS=windows in the script. There are several valid reports where Windows code is not following conventions that are enforced when building for Linux. I wonder whether SIG Windows is aware.
Anyway, I'm not going to pursue this further. If I did, I would have to fix all those issues...
@@ -312,7 +315,8 @@ func Test_convertWinApiToCadvisorApi(t *testing.T) { | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
numOfCores, numOfSockets, nodes, err := convertWinApiToCadvisorApi(tt.buffer) | ||
logger, _ := ktesting.NewTestContext(t) |
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.
nit: this can be done at the beginning of the function, before the main loop.
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.
@bart0sh Thanks for this comment! Let me update it. BTW, do we have any best practices for when we should put it at the beginning of the function vs after the t.Run()
?
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.
In my opinion it should be done in the beginning of the function because it's a test(not a test case) context.
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.
@bart0sh That make senses. Thanks for explanation!
@Chulong-Li Please, rebase on top of the latest master branch. This can potentially fix CI job failures. |
@HirazawaUi Thanks for this information! This kind of failure should be transient. |
Update the order of imports to follow the standard convention Quick update on import order for cadvisor_windows.go Update the hack files Update contextual logging in Test_convertWinApiToCadvisorApi
2667b18
to
0673e9c
Compare
@bart0sh Thanks for all these comments! I've just updated and rebased the code. Hope it would fix that check failure issue. Could you please take another look? |
/retest |
1 similar comment
/retest |
/lgtm /assign @mrunalp @SergeyKanzhelev |
LGTM label has been added. Git tree hash: b15b96feb9252e70a8081fbb6eed46da6cf02db3
|
@Chulong-Li: The following test failed, say
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. |
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. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Migrate pkg/kubelet/winstats to contextual logging
Which issue(s) this PR fixes:
Relates to #130069
Does this PR introduce a user-facing change?