From 6424a045923b9287af82bafbc39a2170d01eb767 Mon Sep 17 00:00:00 2001 From: abushwang Date: Tue, 19 Nov 2024 12:57:32 +0800 Subject: [PATCH] fuse: add kernel fuse passthrough support check Signed-off-by: abushwang --- cmd/containerd-stargz-grpc/main.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cmd/containerd-stargz-grpc/main.go b/cmd/containerd-stargz-grpc/main.go index 82931fd06..4e0d575ae 100644 --- a/cmd/containerd-stargz-grpc/main.go +++ b/cmd/containerd-stargz-grpc/main.go @@ -17,6 +17,7 @@ package main import ( + "bytes" "context" "flag" "fmt" @@ -26,8 +27,10 @@ import ( "net" "net/http" "os" + "os/exec" "os/signal" "path/filepath" + "strings" "time" snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" @@ -132,6 +135,11 @@ func main() { // Create a gRPC server rpc := grpc.NewServer() + // Configure FUSE passthrough + if config.Config.Config.FuseConfig.PassThrough, err = isFusePthEnable(); err != nil { + log.G(ctx).Warnf("failed to check FUSE passthrough support") + } + // Configure keychain credsFuncs := []resolver.Credential{dockerconfig.NewDockerconfigKeychain(ctx)} if config.Config.KubeconfigKeychainConfig.EnableKeychain { @@ -185,6 +193,17 @@ func main() { log.G(ctx).Info("Exiting") } +func isFusePthEnable() (bool, error) { + cmd := exec.Command("sh", "-c", "grep 'CONFIG_FUSE_PASSTHROUGH=y' /boot/config-$(uname -r)") + var out bytes.Buffer + cmd.Stdout = &out + cmd.Stderr = &out + if err := cmd.Run(); err != nil { + return false, err + } + return strings.Contains(out.String(), "CONFIG_FUSE_PASSTHROUGH=y"), nil +} + func serve(ctx context.Context, rpc *grpc.Server, addr string, rs snapshots.Snapshotter, config snapshotterConfig) (bool, error) { // Convert the snapshotter to a gRPC service, snsvc := snapshotservice.FromSnapshotter(rs)