-
Notifications
You must be signed in to change notification settings - Fork 771
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
chore: structured logging for pkg/controller #1629
chore: structured logging for pkg/controller #1629
Conversation
Welcome @jairuigou! It looks like this is your first PR to openkruise/kruise 🎉 |
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.
plz pass structured values directly in the structured logs calls
} else { | ||
klog.V(0).Info("deleted old failed broadcastjob", "job", job, req.NamespacedName) | ||
klog.InfoS("Deleted old failed BroadcastJob", "olbFailedBroadcastJob", klog.KObj(job), "advancedCronJob", req.NamespacedName) |
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.
olbFailedBroadcastJob -》 oldFailedBroadcastJob
@@ -292,7 +292,7 @@ func (r *ReconcileAdvancedCronJob) reconcileBroadcastJob(ctx context.Context, re | |||
tooLate = missedRun.Add(time.Duration(*advancedCronJob.Spec.StartingDeadlineSeconds) * time.Second).Before(now) | |||
} | |||
if tooLate { | |||
klog.V(1).Info("missed starting deadline for last run, sleeping till next", "current run", missedRun, req.NamespacedName) | |||
klog.V(1).InfoS("Missed starting deadline for last run, sleeping till next current run", "missedRun", missedRun, "advancedCronJob", req.NamespacedName) |
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.
"Missed starting deadline for last run, sleeping till next current run" -> "Missed starting deadline for last run, sleeping till next run"
@@ -285,7 +285,7 @@ func (r *ReconcileAdvancedCronJob) reconcileJob(ctx context.Context, req ctrl.Re | |||
If we've missed a run, and we're still within the deadline to start it, we'll need to run a job. | |||
*/ | |||
if missedRun.IsZero() { | |||
klog.V(1).Info("no upcoming scheduled times, sleeping until next now ", now, " and next run ", nextRun, req.NamespacedName) | |||
klog.V(1).InfoS("No upcoming scheduled times, sleeping until next now and next run", "nextNow", now, "nextRun", nextRun, "advancedCronJob", req.NamespacedName) |
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 upcoming scheduled times, sleeping until next now and next run" -> "No upcoming scheduled times, sleeping until next run"
and replace "nextNow" with "now"
@@ -282,7 +282,7 @@ func (r *ReconcileAdvancedCronJob) reconcileBroadcastJob(ctx context.Context, re | |||
If we've missed a run, and we're still within the deadline to start it, we'll need to run a job. | |||
*/ | |||
if missedRun.IsZero() { | |||
klog.V(1).Info("no upcoming scheduled times, sleeping until next now ", now, " and next run ", nextRun, req.NamespacedName) | |||
klog.V(1).InfoS("No upcoming scheduled times, sleeping until next now and next run", "nextNow", now, "nextRun", nextRun, "advancedCronJob", req.NamespacedName) |
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 upcoming scheduled times, sleeping until next now " -》 "No upcoming scheduled times, sleeping until next run"
and replace "nextNow" with "now"
return reconcile.Result{}, err | ||
} | ||
|
||
if scaleSatisfied, unsatisfiedDuration, scaleDirtyPods := scaleExpectations.SatisfiedExpectations(request.String()); !scaleSatisfied { | ||
if unsatisfiedDuration >= expectations.ExpectationTimeout { | ||
klog.Warningf("Expectation unsatisfied overtime for bcj %v, scaleDirtyPods=%v, overtime=%v", request.String(), scaleDirtyPods, unsatisfiedDuration) | ||
klog.InfoS("Expectation unsatisfied overtime for BroadcastJob", "broadcastJob", request.String(), "scaleDirtyPods", scaleDirtyPods, "overtime", unsatisfiedDuration) |
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.
plz pass structured value directly without .string(), replace request.String() with request
return reconcile.Result{RequeueAfter: expectations.ExpectationTimeout - unsatisfiedDuration}, nil | ||
} | ||
|
||
// If resourceVersion expectations have not satisfied yet, just skip this reconcile | ||
resourceVersionExpectations.Observe(job) | ||
if isSatisfied, unsatisfiedDuration := resourceVersionExpectations.IsSatisfied(job); !isSatisfied { | ||
if unsatisfiedDuration >= expectations.ExpectationTimeout { | ||
klog.Warningf("Expectation unsatisfied overtime for %v, timeout=%v", request.String(), unsatisfiedDuration) | ||
klog.InfoS("Expectation unsatisfied overtime", "imagePullJob", request.String(), "timeout", unsatisfiedDuration) |
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.
replace request.String() with request
return reconcile.Result{}, nil | ||
} | ||
klog.V(4).Infof("Not satisfied resourceVersion for %v", request.String()) | ||
klog.V(4).InfoS("Not satisfied resourceVersion", "imagePullJob", request.String()) |
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.
replace request.String() with request
@@ -238,10 +238,10 @@ func (r *ReconcileImagePullJob) Reconcile(_ context.Context, request reconcile.R | |||
resourceVersionExpectations.Observe(nodeImage) | |||
if isSatisfied, unsatisfiedDuration := resourceVersionExpectations.IsSatisfied(nodeImage); !isSatisfied { | |||
if unsatisfiedDuration >= expectations.ExpectationTimeout { | |||
klog.Warningf("Expectation unsatisfied overtime for %v, wait for NodeImage %v updating, timeout=%v", request.String(), nodeImage.Name, unsatisfiedDuration) | |||
klog.InfoS("Expectation unsatisfied overtime, waiting for NodeImage updating", "imagePullJob", request.String(), "nodeImageName", nodeImage.Name, "timeout", unsatisfiedDuration) |
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.
replace request.String() with request
return reconcile.Result{}, nil | ||
} | ||
klog.V(4).Infof("Not satisfied resourceVersion for %v, wait for NodeImage %v updating", request.String(), nodeImage.Name) | ||
klog.V(4).InfoS("Not satisfied resourceVersion, waiting for NodeImage updating", "imagePullJob", request.String(), "nodeImageName", nodeImage.Name) |
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.
replace request.String() with request
var requeueMsg string | ||
defer func() { | ||
if err != nil { | ||
klog.Warningf("Failed to process NodeImage %v err %v, elapsedTime %v", request.Name, time.Since(start), err) | ||
klog.InfoS("Failed to process NodeImage", "nodeImageName", request.Name, "elapsedTime", time.Since(start), "err", err) |
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.
replace InfoS with ErrorS
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1629 +/- ##
==========================================
+ Coverage 47.91% 49.46% +1.54%
==========================================
Files 162 183 +21
Lines 23491 18997 -4494
==========================================
- Hits 11256 9396 -1860
+ Misses 11014 8378 -2636
- Partials 1221 1223 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
plz squash the commits into one |
f123e71
to
bd4d38e
Compare
/lgtm |
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.
plz also rebase the master for changes
return false | ||
} | ||
|
||
for _, pod := range pods { | ||
dsc.resourceVersionExpectations.Observe(pod) | ||
if isSatisfied, unsatisfiedDuration := dsc.resourceVersionExpectations.IsSatisfied(pod); !isSatisfied { | ||
if unsatisfiedDuration >= kruiseExpectations.ExpectationTimeout { | ||
klog.Errorf("Expectation unsatisfied resourceVersion overtime for %v, wait for pod %v updating, timeout=%v", dsKey, pod.Name, unsatisfiedDuration) | ||
klog.ErrorS(fmt.Errorf("expectation unsatisfied resourceVersion overtime for DaemonSet, wait for pod updating"), |
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.
plz just pass nil as error in the ErrorS,
plz change similar logging lines too, pass nil error to ErrorS if no explicit error is available in the 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.
done
Signed-off-by: jairui <jairuigou@gmail.com>
bd4d38e
to
32a6fb0
Compare
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: zmberg 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 |
Ⅰ. Describe what this PR does
Support structured logging for
pkg/controller
Ⅱ. Does this pull request fix one issue?
#1551
Ⅲ. Describe how to verify it
use k8s.io/klog/hack/tools/logcheck
logcheck -check-structured ./pkg/controller/...
Ⅳ. Special notes for reviews