-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
🌱 log to logger from context during drain #6170
🌱 log to logger from context during drain #6170
Conversation
Signed-off-by: Stefan Büringer buringerst@vmware.com
@@ -530,8 +529,10 @@ func (r *Reconciler) drainNode(ctx context.Context, cluster *clusterv1.Cluster, | |||
log.Info(fmt.Sprintf("%s pod from Node", verbStr), | |||
"pod", fmt.Sprintf("%s/%s", pod.Name, pod.Namespace)) | |||
}, | |||
Out: writer{klog.Info}, | |||
ErrOut: writer{klog.Error}, | |||
Out: writer{log.Info}, |
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.
I think log level 0 is too high for those logs. What should we use?
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.
Given that it deals with users' workloads I don't mind being verbose here.
But probably we will get back to this soon with more context as soon as we consolidate log improvements actions
/test pull-cluster-api-test-mink8s-main |
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.
/lgtm
ErrOut: writer{klog.Error}, | ||
Out: writer{log.Info}, | ||
ErrOut: writer{func(msg string, keysAndValues ...interface{}) { | ||
log.Error(nil, msg, keysAndValues) |
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.
Not sure if we should log the whole message as error or log it as I currently did.
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.
I think this is fine as you've done it here.
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.
/lgtm
@fabriziopandini Do we want to merge it? |
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri 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 |
Signed-off-by: Stefan Büringer buringerst@vmware.com
What this PR does / why we need it:
Apart from main functions and test code we should never use the global klog logger.
By using the one from the context we can make sure that the log lines have the right k/v pairs.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #