Skip to content

Commit

Permalink
fusemanager: resolve review comments
Browse files Browse the repository at this point in the history
Signed-off-by: abushwang <[email protected]>
  • Loading branch information
wswsmao committed Dec 9, 2024
1 parent 5a4c3ff commit 0b5689f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
4 changes: 2 additions & 2 deletions cmd/containerd-stargz-grpc/fsopts/fsopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ type Config struct {
}

const (
memoryMetadataType = "memory"
dbMetadataType = "db"
memoryMetadataType = "memory"
dbMetadataType = "db"
)

func ConfigFsOpts(ctx context.Context, rootDir string, config *Config) ([]fs.Option, error) {
Expand Down
19 changes: 7 additions & 12 deletions cmd/containerd-stargz-grpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import (
"github.com/pelletier/go-toml"
"golang.org/x/sys/unix"
"google.golang.org/grpc"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

const (
Expand All @@ -55,10 +54,10 @@ const (
defaultLogLevel = log.InfoLevel
defaultRootDir = "/var/lib/containerd-stargz-grpc"
defaultImageServiceAddress = "/run/containerd/containerd.sock"
defaultFuseManagerAddress = "/run/containerd-stargz-grpc/fuse-namanger.sock"
defaultFuseManagerAddress = "/run/containerd-stargz-grpc/fuse-manager.sock"

fuseManagerBin = "stargz-fuse-manager"
fuseManagerAddress = "fuse-mananger.sock"
fuseManagerAddress = "fuse-manager.sock"
)

var (
Expand Down Expand Up @@ -148,15 +147,6 @@ func main() {
ImageServicePath: config.CRIKeychainConfig.ImageServicePath,
}

credsFuncs, criServer, err := keychainconfig.ConfigKeychain(ctx, &keyChainConfig)
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to configure keychain")
}

if config.Config.CRIKeychainConfig.EnableKeychain {
runtime.RegisterImageServiceServer(rpc, criServer)
}

var rs snapshots.Snapshotter
if *detachFuseManager {
fmPath := config.FuseManagerPath
Expand Down Expand Up @@ -197,6 +187,11 @@ func main() {
}
log.G(ctx).Infof("Start snapshotter with fusemanager mode")
} else {
credsFuncs, err := keychainconfig.ConfigKeychain(ctx, rpc, &keyChainConfig)
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to configure keychain")
}

fsConfig := fsopts.Config{
EnableIpfs: config.IPFS,
MetadataStore: config.MetadataStore,
Expand Down
20 changes: 10 additions & 10 deletions cmd/stargz-fuse-manager/fusemanager/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ const (
)

type Config struct {
Config *service.Config
IPFS bool
MetadataStore string
Config *service.Config
IPFS bool
MetadataStore string
DefaultImageServiceAddress string
}

Expand Down Expand Up @@ -87,12 +87,12 @@ func NewFuseManager(ctx context.Context, listener net.Listener, server *grpc.Ser
}

fm := &Server{
status: FuseManagerWaitInit,
lock: sync.RWMutex{},
fsMap: sync.Map{},
ms: db,
listener: listener,
server: server,
status: FuseManagerWaitInit,
lock: sync.RWMutex{},
fsMap: sync.Map{},
ms: db,
listener: listener,
server: server,
fuseStoreAddr: fuseStoreAddr,
}

Expand Down Expand Up @@ -136,7 +136,7 @@ func (fm *Server) Init(ctx context.Context, req *pb.InitRequest) (*pb.Response,
ImageServicePath: config.Config.CRIKeychainConfig.ImageServicePath,
}

credsFuncs, _, err := keychainconfig.ConfigKeychain(ctx, &keyChainConfig)
credsFuncs, err := keychainconfig.ConfigKeychain(ctx, fm.server, &keyChainConfig)
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to configure keychain")
}
Expand Down
2 changes: 1 addition & 1 deletion fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func NewFilesystem(root string, cfg config.Config, opts ...Option) (_ snapshot.F
logLevel = *fsOpts.metricsLogLevel
}
commonmetrics.Register(logLevel) // Register common metrics. This will happen only once.
metrics.Register(ns) // Register layer metrics.
metrics.Register(ns) // Register layer metrics.
}
if metricsCtr == nil {
metricsCtr = layermetrics.NewLayerMetrics(ns)
Expand Down
9 changes: 4 additions & 5 deletions service/keychain/keychainconfig/keychainconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ type Config struct {
ImageServicePath string
}

func ConfigKeychain(ctx context.Context, config *Config) ([]resolver.Credential, runtime.ImageServiceServer, error) {
func ConfigKeychain(ctx context.Context, rpc *grpc.Server, config *Config) ([]resolver.Credential, error) {
credsFuncs := []resolver.Credential{dockerconfig.NewDockerconfigKeychain(ctx)}
var criServer runtime.ImageServiceServer
if config.EnableKubeKeychain {
var opts []kubeconfig.Option
if kcp := config.KubeconfigPath; kcp != "" {
Expand All @@ -63,12 +62,12 @@ func ConfigKeychain(ctx context.Context, config *Config) ([]resolver.Credential,
}
return runtime.NewImageServiceClient(conn), nil
}
f, server := cri.NewCRIKeychain(ctx, connectCRI)
f, criServer := cri.NewCRIKeychain(ctx, connectCRI)
runtime.RegisterImageServiceServer(rpc, criServer)
credsFuncs = append(credsFuncs, f)
criServer = server
}

return credsFuncs, criServer, nil
return credsFuncs, nil
}

func newCRIConn(criAddr string) (*grpc.ClientConn, error) {
Expand Down

0 comments on commit 0b5689f

Please sign in to comment.