Skip to content

Commit

Permalink
Add go-fuse logger
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Kern-- authored and turan18 committed Oct 16, 2023
1 parent 01edc65 commit 104c68c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ package fs
import (
"context"
"fmt"
golog "log"
"os/exec"
"sync"
"syscall"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 104c68c

Please sign in to comment.