-
Notifications
You must be signed in to change notification settings - Fork 39.5k
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
job controller: use contextual logging #113576
job controller: use contextual logging #113576
Conversation
@sanwishe: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. 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. |
@sanwishe: 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. |
0415438
to
fb1d691
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.
/release-note-none
2bf3cda
to
5afbd11
Compare
5afbd11
to
8786ec7
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sanwishe 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 |
/assign |
@sanwishe: 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/test-infra repository. |
/remove-sig api-machinery |
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.
Generally looks good, with some remarks:
- One more klog line in
tracking_utils
to replace:
klog.V(4).InfoS("Expecting tracking finalizers removed", "job", jobKey, "podUIDs", deletedKeys)
. - a question about wrapping with
LoggerWithName
- a suggestion to use
key
for job logging identifier where available
@@ -442,15 +451,15 @@ func (jm *Controller) updateJob(old, cur interface{}) { | |||
total := time.Duration(*curADS) * time.Second | |||
// AddAfter will handle total < passed | |||
jm.queue.AddAfter(key, total-passed) | |||
klog.V(4).Infof("job %q ActiveDeadlineSeconds updated, will rsync after %d seconds", key, total-passed) | |||
klog.FromContext(ctx).V(4).Info("Job's ActiveDeadlineSeconds updated, will rsync", "job", klog.KObj(curJob), "interval", total-passed) |
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: suggesting using key
instead of klog.KObj(curJob)
since already at hand, and to be consistent with other places like this: klog.FromContext(ctx).Info("Enqueueing job", "job", key)
.
@@ -188,8 +196,9 @@ func (jm *Controller) Run(ctx context.Context, workers int) { | |||
defer jm.queue.ShutDown() | |||
defer jm.orphanQueue.ShutDown() | |||
|
|||
klog.Infof("Starting job controller") | |||
defer klog.Infof("Shutting down job controller") | |||
logger := klog.LoggerWithName(klog.FromContext(ctx), "Job") |
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.
Why to wrap the logger here by klog.LoggerWithName
, but not in in other places within the job_controller?
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.
Please take out LoggerWithName
. We plan to add the names one level up in the caller of this function.
If you still need this PR then please rebase, if not, please close the PR |
The changelog entry I suggest for this: Migrated the Job controller (within `kube-controller-manager) to use [contextual logging](https://k8s.io/docs/concepts/cluster-administration/system-logs/#contextual-logging). |
@sanwishe: ping. Can you rebase and address comments? |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle stale |
PR #116910 has already done this part of the work, so we can close the PR. |
/close |
@mengjiao-liu: Closed this PR. 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. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Switch the job controller code to use contextual and structured logging.
Which issue(s) this PR fixes:
Fixes #
Part of 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.: