Skip to content

Commit

Permalink
fuse: add kernel fuse passthrough support check
Browse files Browse the repository at this point in the history
Signed-off-by: abushwang <[email protected]>
  • Loading branch information
wswsmao committed Nov 19, 2024
1 parent 71930d7 commit 6424a04
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/containerd-stargz-grpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package main

import (
"bytes"
"context"
"flag"
"fmt"
Expand All @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6424a04

Please sign in to comment.