-
Notifications
You must be signed in to change notification settings - Fork 223
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
add log filename and line number #252
add log filename and line number #252
Conversation
Hi @cmssczy. Thanks for your PR. I'm waiting for a kubernetes-sigs 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. |
bee7083
to
1bc605f
Compare
/ok-to-test |
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.
/approve
@@ -26,6 +26,7 @@ import ( | |||
// to ensure that exec-entrypoint and run can make use of them. | |||
_ "k8s.io/client-go/plugin/pkg/client/auth" | |||
|
|||
zaplog "go.uber.org/zap" |
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.
just zap
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 imported "sigs.k8s.io/controller-runtime/pkg/log/zap"
before.
@@ -70,6 +71,7 @@ func main() { | |||
|
|||
opts := zap.Options{ | |||
TimeEncoder: zapcore.RFC3339NanoTimeEncoder, | |||
ZapOpts: []zaplog.Option{zaplog.AddCaller(), zaplog.AddCallerSkip(-1)}, |
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.
What's the skip for?
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 cannot get the right caller
if we do not add zaplog.AddCallerSkip(-1)
.
we get some logs like this:
"caller":"controller/controller.go:114","msg":"Job is suspended and workload not yet admitted by a clusterQueue, nothing to do",
In fact this log should be printed at pkg/controller/workload/job/job_controller.go:208
.
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.
What about other log lines? For example, the ones coming from the scheduler.
I'm wondering if controller-runtime is increasing the Skip somewhere just when calling Reconcile.
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 controller-runtime will add 1 Skip in controller-runtime/pkg/log/zap/zap.go. Maybe we should descrease 1?
there is an issue to track this problem: kubernetes-sigs/controller-runtime#1737
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.
logs in scheduler.go:
{"level":"Level(-2)","ts":"2022-05-10T02:37:06.627754573Z","logger":"scheduler","caller":"scheduler/scheduler.go:306","msg":"Workload assumed in the cache","workload":{"name":"sample-job-hw88n","namespace":"default"},"clusterQueue":{"name":"cluster-total"}} {"level":"Level(-3)","ts":"2022-05-10T02:37:06.627876656Z","logger":"scheduler","caller":"scheduler/scheduler.go:137","msg":"Workload evaluated for admission","workload":{"name":"sample-job-hw88n","namespace":"default"},"clusterQueue":{"name":"cluster-total"},"status":"assumed","reason":""}
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.
Are those logs with the -1
you added?
If so, then I'm fine leaving it and then we can remove it once kubernetes-sigs/controller-runtime#1737 is fixed.
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.
Are those logs with the
-1
you added?
These logs are not added by me. Line number was not correct because I pushed these code based on the old commit(e5fdd9b)
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.
Let me restate the question:
Do the logs for scheduler.go file look accurate when using the code in this PR?
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.
kueue/pkg/scheduler/scheduler.go
Lines 303 to 307 in e5fdd9b
if err := s.cache.AssumeWorkload(newWorkload); err != nil { | |
return err | |
} | |
log.V(2).Info("Workload assumed in the cache") | |
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.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alculquicondor, cmssczy 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 |
zap.WriteTo(ginkgo.GinkgoWriter), | ||
zap.UseDevMode(true), | ||
zap.Level(zapcore.Level(-3)), | ||
zap.UseFlagOptions(&opts)), |
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.
This is probably overriding the level above, @kerthcet. We should set the options as a function.
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.
Thanks aldo, I'll have a test then.
Signed-off-by: cmssczy smartczy@outlook.com
What type of PR is this?
/kind feature
What this PR does / why we need it:
print filename and line number in log
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
you can see
caller
in log