-
Notifications
You must be signed in to change notification settings - Fork 24
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
Added improved logging #101
Added improved logging #101
Conversation
cmd/plugin/node_server.go
Outdated
klog.Infof("mount request: %s", req.String()) | ||
u, _ := uuid.NewRandom() | ||
valuesLogger := klog.LoggerWithValues(klog.NewKlogr(), "pod-name", req.VolumeContext["pod-name"], "namespace", req.VolumeContext["namespace"], "uid", req.VolumeContext["uid"], "request-id", u.String()) | ||
valuesLogger.Info(fmt.Sprintf("mount request: %s", req.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.
valuesLogger.Info(fmt.Sprintf(...))
is messy but klogr doesn't support infof()
.
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.
You might want to check klog.SetLogFilter()
(you basically pass in a function which is called every time something is logged and add the sticky values there) or klog.SetLogger()
Another option is to use zap's SugarLogger instead of klog's logger but I think that might need more discussion.
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 followed the advice here for converting format strings to structured logs. Open to discussion though
Co-authored-by: Mugdha Adhav <mugdha.adhav@gmail.com>
Co-authored-by: Mugdha Adhav <mugdha.adhav@gmail.com>
Co-authored-by: Mugdha Adhav <mugdha.adhav@gmail.com>
I'm still running into problems getting the correct image size:
Checking the image via the containerd cli shows it's 3.1 KiB:
And the dockerhub page for the simple-fs tag says 360 B: I tried with another image docker/transfused and it's the same story: csi image says
|
pkg/remoteimage/pull.go
Outdated
// Returns the size of the image that was pulled in MB(I think?) **TODO: check** | ||
func (p puller) ImageSize(ctx context.Context) int { | ||
imageSpec := &cri.ImageSpec{Image: p.image.String()} | ||
return imageSpec.Size() |
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 not correct to get the size of an image. After checking the implementation of the ImageSpec.Size, I found that the Puller.ImageSize will always return the length of the image reference, that is, p.image here.
The image size can be fetched through 'ImageServiceClient.ImageStatus'. The committed code can be used to get the extracted image size instead.
Updated the image size code and things good now:
And here's what
For nginx, here's the log message saying 67.25 MiB
Which matches what
As well as the dockerhub page. |
@gesarki You have the log message key reversed -
|
@gesarki On the note of image size, see containerd/containerd#9261. |
cmd/plugin/node_server.go
Outdated
@@ -59,7 +60,9 @@ type NodeServer struct { | |||
} | |||
|
|||
func (n NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (resp *csi.NodePublishVolumeResponse, err error) { | |||
klog.Infof("mount request: %s", req.String()) | |||
u, _ := uuid.NewRandom() | |||
valuesLogger := klog.LoggerWithValues(klog.NewKlogr(), "pod-name", req.VolumeContext["pod-name"], "namespace", req.VolumeContext["namespace"], "uid", req.VolumeContext["uid"], "request-id", u.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.
Will this information, the additional key-values, added to all logs from the moment a new request comes in, not make the logs noisy?
I suggest not adding all these key-values via LoggerWithValues
, but rather logging just the request itself. An example in aws-ebs-csi-driver
Even if all the key-values are desired to be added to all logs, might I suggest increasing the V
level - V(4)
, such that only on increasing the verbosity level do you see such verbose logs.
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 extra key-values will only be added to logs called valuesLogger
, i.e. valuesLogger.Info()
or valuesLogger.Error()
, etc. We're just using it for logs that we want to include those key-values. The reason is we want to be able to track individual requests as they come in, start pulling, finish pulling, start mounting, finish mounting. Including the random UIDs and context info help to be able to track requests especially as pulls can be asynchronous now.
Attached is a sample log from one async pull. You can see it's just a select few messages that are logged sample-log.txt
Co-authored-by: Mriyam Tamuli <mbtamuli@gmail.com>
@gesarki You'll need to rebase once. |
@@ -160,3 +160,6 @@ See [test/sanity](/~https://github.com/warm-metal/csi-driver-image/tree/master/tes | |||
### E2E test | |||
|
|||
See [test/e2e](/~https://github.com/warm-metal/csi-driver-image/tree/master/test/e2e). | |||
|
|||
## Note on logging image size |
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.
👍
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.
Changes are looking good, and thanks for updating the documentation.
Before merging, I am also updating Makefile
and Chart.yaml
in the same PR. Created #119 for improving this process.
What
Adds the following information in the logs for each image pull and mount
Why
So we have better insight into the performance of the warm metal node plugin and to facilitate debugging.
Addition information
Here's what it looks like in action:
