From 104c68c2c6e9c3e10770413862d17f237c9a2600 Mon Sep 17 00:00:00 2001 From: Kern Walster Date: Fri, 6 Oct 2023 18:35:53 +0000 Subject: [PATCH] Add go-fuse logger soci-snapshotter-gprc overrides the default logger to be a logrus logger with debug as the write level. If the snapshotter is invoked with `--log-level debug`, then logs from e.g. `log.PrinLn` are visibile. go-fuse uses this logging method to output a complete transaction of fuse operations keeping track of each request/response with a unique id. The ID is only unique within a single server, so trying to parse the logs is ambiguous since you don't know which server a response corresponds to. go-fuse recently added support for per-server loggers. This change uses that functionality to add the layer digest to the logs from each fuse server so request/response pairs can be unambiguously matched. It also changes the log level of go-fuse logs to trace since there really is no debug reason for enabling them. Signed-off-by: Kern Walster --- fs/fs.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/fs.go b/fs/fs.go index 24a9f8298..e780122e9 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -45,6 +45,7 @@ package fs import ( "context" "fmt" + golog "log" "os/exec" "sync" "syscall" @@ -494,10 +495,16 @@ func (fs *filesystem) Mount(ctx context.Context, mountpoint string, labels map[s NegativeTimeout: &fs.negativeTimeout, NullPermissions: true, }) + // Pass in a logger to go-fuse with the layer digest + // The go-fuse logs are useful for tracing exactly what's happening at the fuse level. + logger := log.L. + WithField("layerDigest", labels[ctdsnapshotters.TargetLayerDigestLabel]). + WriterLevel(logrus.TraceLevel) mountOpts := &fuse.MountOptions{ AllowOther: true, // allow users other than root&mounter to access fs FsName: "soci", // name this filesystem as "soci" Debug: fs.debug, + Logger: golog.New(logger, "", 0), } if _, err := exec.LookPath(fusermountBin); err == nil { mountOpts.Options = []string{"suid"} // option for fusermount; allow setuid inside container