Skip to content

Add fuse-manager #1892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2024
Merged

Add fuse-manager #1892

merged 1 commit into from
Dec 13, 2024

Conversation

wswsmao
Copy link
Contributor

@wswsmao wswsmao commented Dec 9, 2024

Thanks to @ilyee, the author of PR #324 for his permission, this work can be resumed.

In light of the project's evolution over the past two years, the following adjustments have been made compared to the original content:

  1. Two configuration packages have been added, including fsopts and keychainconfig. The main file now utilizes the interfaces provided by the configuration package to set up the main process, eliminating the need for each main package to repeat the configuration steps.
  2. Resource cleanup has been implemented for fusemanager.
  3. Feedback from the review of PR #324 has been addressed.

@wswsmao wswsmao force-pushed the main branch 11 times, most recently from 80cee15 to e015180 Compare December 11, 2024 07:51
Copy link
Member

@ktock ktock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Could you add Co-authored-by for @ilyee in the commit messages?

fmAddr := config.FuseManagerAddress
if fmAddr == "" {
var err error
fmAddr, err = exec.LookPath(fuseManagerAddress)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always expect an absolute path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

cmd/go.mod Outdated
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.0
github.com/opencontainers/runtime-spec v1.2.0
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use this package because this has been archived

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 50 to 53
Config *service.Config
IPFS bool
MetadataStore string
DefaultImageServiceAddress string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add JSON tags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,58 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have fusemanager package in the repo root?

Copy link
Contributor Author

@wswsmao wswsmao Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have fusemanager package in the repo root?

I have tried two approaches:

  1. Placing the fusemanager in the repository root. However, since the fsopts package is located in the cmd directory, building directly leads to issues where fusemanager cannot find fsopts. This requires adding fsopts separately to the go.mod file, which would introduce a significant number of dependencies.

  2. Keeping the service.go file that depends on fsopts, along with the fusemanager.go and fusestore.go files, in the cmd/stargz-fuse-manager directory, while only moving the client-side content to the repository root.

I was wondering if there might be a better solution

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pass fsopts.ConfigFsOpts to fusemanager as a callback function so that we can eliminate direct dependency from fusemanager to fsopts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

snOpts := []snbase.Opt{snbase.AsynchronousRemove}
if config.SnapshotterConfig.AllowInvalidMountsOnRestart {
snOpts = append(snOpts, snbase.AllowInvalidMountsOnRestart)
func StartFuseManager(ctx context.Context, executable, address, fusestore, logLevel, logPath string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put this in fusemounter package because this seem to be independent to service package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,just mv it to fusemanager/fusemanager.go


mt, err := getMetadataStore(rootDir, config)
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to configure metadata store")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fatal exits the process here. This line isn't needed and just do return nil, fmt.Errorf("failed to configure metadata store: %w", err)
The same applies to other places as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

func runFuseManager(ctx context.Context) error {
lvl, err := logrus.ParseLevel(logLevel)
if err != nil {
log.L.WithError(err).Fatal("failed to prepare logger")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


credsFuncs, err := keychainconfig.ConfigKeychain(ctx, fm.server, &keyChainConfig)
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to configure keychain")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return an error (also the same for other places in this file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -66,6 +69,27 @@ func WithFilesystemOptions(opts ...stargzfs.Option) Option {

// NewStargzSnapshotterService returns stargz snapshotter.
func NewStargzSnapshotterService(ctx context.Context, root string, config *Config, opts ...Option) (snapshots.Snapshotter, error) {
fs, err := NewFileSystem(ctx, root, config, opts...)
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to configure filesystem")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return an error (also the same for other places in this file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@wswsmao
Copy link
Contributor Author

wswsmao commented Dec 12, 2024

Thanks. Could you add Co-authored-by for @ilyee in the commit messages?

done, I have squash these commit and add Co-authored-by for @ilyee

@wswsmao wswsmao force-pushed the main branch 2 times, most recently from ffc8b65 to 58a325c Compare December 12, 2024 09:26
Copy link
Member

@ktock ktock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to enable fusemanager in the tests in our CI (can be following up though)

return nil
}

func (fm *Server) clearMounts(ctx context.Context) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stargz snapshotter (snapshot/snapshot.go) already has the similar cleanup logic. Can we just rely on it or why we need this in fusemanager? It needs documents about how to restart fusemanager (e.g. for upgrading).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

  1. clearMounts is unnecessary and has been deleted.
  2. add Upgrading Fuse Manager to overview.md

func runFuseManager(ctx context.Context) error {
lvl, err := logrus.ParseLevel(logLevel)
if err != nil {
log.L.WithError(err).Fatal("failed to prepare logger")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #1892 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


snapshotter, err = snbase.NewSnapshotter(ctx, snapshotterRoot(root), fs, snOpts...)
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to create new snapshotter")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #1892 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -66,6 +67,29 @@ func WithFilesystemOptions(opts ...stargzfs.Option) Option {

// NewStargzSnapshotterService returns stargz snapshotter.
func NewStargzSnapshotterService(ctx context.Context, root string, config *Config, opts ...Option) (snapshots.Snapshotter, error) {
fs, err := NewFileSystem(ctx, root, config, opts...)
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to configure filesystem")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #1892 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@wswsmao wswsmao force-pushed the main branch 3 times, most recently from 48731b5 to 29532df Compare December 13, 2024 09:02
Signed-off-by: abushwang <[email protected]>
Co-authored-by: Zuti He <[email protected]>
Copy link
Member

@ktock ktock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@ktock ktock merged commit 4e10317 into containerd:main Dec 13, 2024
26 checks passed
@ktock ktock mentioned this pull request Dec 13, 2024
@wswsmao wswsmao mentioned this pull request Dec 17, 2024
@ktock ktock mentioned this pull request Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants