-
Notifications
You must be signed in to change notification settings - Fork 404
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
[Logging] add context info for yunikorn logger #2522
Conversation
cc @kevin85421 |
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.
Is it possible to pass ctx
from RayCluster reconciler to YuniKorn's constructor instead?
kuberay/ray-operator/controllers/ray/batchscheduler/yunikorn/yunikorn_scheduler.go
Lines 110 to 114 in b81af7c
func (yf *YuniKornSchedulerFactory) New(_ *rest.Config) (schedulerinterface.BatchScheduler, error) { | |
return &YuniKornScheduler{ | |
log: logf.Log.WithName(SchedulerName), | |
}, nil | |
} |
The code should look like:
func (yf *YuniKornSchedulerFactory) New(ctx, _ *rest.Config) (schedulerinterface.BatchScheduler, error) {
logger := ctrl.LoggerFrom(ctx).WithName(SchedulerName)
return &YuniKornScheduler{
log: logger
}, nil
}
d5ac8f8
to
1c7f087
Compare
Can you rebase with the master branch? I just fixed a CI issue. |
f23ae57
to
95c3830
Compare
Hi @kevin85421, I tried the method you suggested, but upon checking the logs, there is no RayCluster context.
Or should I use |
Oh, I found that |
I read controller-runtime's source code, and I found it reconstruct the logger inside I think persisting and reusing the logger may cause issues. Maybe we need to pass logger := ctrl.LoggerFrom(ctx).WithName(...) |
95c3830
to
a9c7295
Compare
a9c7295
to
b14e902
Compare
Signed-off-by: win5923 <[email protected]>
b14e902
to
917a909
Compare
The log are as follows:
|
ray-operator/controllers/ray/batchscheduler/schedulermanager.go
Outdated
Show resolved
Hide resolved
ray-operator/controllers/ray/batchscheduler/schedulermanager.go
Outdated
Show resolved
Hide resolved
45e5653
to
af2f558
Compare
Why are these changes needed?
Add a helper method to generate a logger that includes RayCluster name and namespace. This can reduce the repetitive code of manually adding context of Raycluster for yunikorn logger.
Before:
After:
Related issue number
Closes #2408
Checks