-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Migrate pkg/proxy
to contextual logging: Part 1
#122979
Migrate pkg/proxy
to contextual logging: Part 1
#122979
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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. |
Hi @fatsheep9146. 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/test-infra repository. |
/label sig/instrumentation |
@fatsheep9146: The label(s) 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/test-infra repository. |
/wg structured-logging |
The "per-proxier" logger should have logger = logger.WithValues("family", ipFamily) In dual-stack there are two instances of the "proxier", one for IPv4 and one for IPv6. They log individually and often with the same message (and values). It is useful to see which of the proxiers that encounters an error for example. I had a short discussion with @pohly on slack about performance, and it is fine to create a logger WithValues once. I made the change above and tested. Here is a sample (json logging used): {
"ts": 1706546611912.709,
"caller": "iptables/proxier.go:630",
"msg": "Updated proxier node labels",
"v": 4,
"family": "IPv4",
"labels": {
"beta.kubernetes.io/arch": "amd64",
"beta.kubernetes.io/os": "linux",
"kubernetes.io/arch": "amd64",
"kubernetes.io/hostname": "vm-002",
"kubernetes.io/os": "linux"
}
}
{
"ts": 1706546611912.75,
"caller": "iptables/proxier.go:630",
"msg": "Updated proxier node labels",
"v": 4,
"family": "IPv6",
"labels": {
"beta.kubernetes.io/arch": "amd64",
"beta.kubernetes.io/os": "linux",
"kubernetes.io/arch": "amd64",
"kubernetes.io/hostname": "vm-002",
"kubernetes.io/os": "linux"
}
} |
You should probably monitor this |
Thanks! I will take this into account. |
4178a58
to
239ea97
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.
Overall LGTM, few suggestions.
ced8e83
to
bfbb11f
Compare
The "root logger" proposed in #122979 (comment) is not included. I think this will be needed in the future, but it's not urgent. Now the global logger is used, which should be ok for now. /lgtm (my lgtm will be valid for ipvs only. @danwinship may approve other changes) |
LGTM label has been added. Git tree hash: 3544916c905b21be2e77dd83136e5179ac2dc22e
|
@danwinship could you help review this again? |
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
bfbb11f
to
be4535b
Compare
/retest |
1 similar comment
/retest |
@fatsheep9146: 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/test-infra repository. I understand the commands that are listed here. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: danwinship, fatsheep9146, uablrek 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 |
/lgtm (label was lost after rebase) (https://github.com/kubernetes/kubernetes/compare/bfbb11ff3f71de275f4d9b22d07babcaf02ab0fe..be4535bd34ac09e57a0b1c478cbcebd051a42598 ) |
LGTM label has been added. Git tree hash: 5a79ecafbd4393b62950efd0e4fae6d9df569a1a
|
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Use contextual logging for
pkg/proxy
After trying to convert
pkg/proxy
to contextual logging in one pr, I found it's hard to make it and will let the pr grow too large to review.So I deciced to split the converting job into several parts, here is the part 1.
In this part, I focus on serveral things
cmd/kube-proxy
to usecontext.Context
notklog.Logger
as input parameters as @danwinship suggested inOriginally posted by @danwinship in #122197 (review)
logger
instance in structProxyServer
, since the "add logger to instance" is often not good option as @pholy saidOriginally posted by @pohly in #122197 (comment)
proxy.Provider
, for example thelogger
field in structiptables.Proxier
, the reason is that eachproxy.Provider
will be called as a informer event handler inProxyServer
, there is not a good place to add logger from outside. And there are also some key/values can only be got inside the library of proxy.Provider, for example ipFamily.Which issue(s) this PR fixes:
Related kubernetes/enhancements#3077
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: