Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
make sure that the snapshotter can start even from an unknow state
Browse files Browse the repository at this point in the history
  • Loading branch information
siscia committed Oct 16, 2020
1 parent 0ece4bc commit 41cf87a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cvmfs/cvmfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func NewFilesystem(ctx context.Context, root string, config *Config) (snapshot.F
absolutePath = config.AbsoluteMountpoint
}
log.G(ctx).WithField("root", root).WithField("absolutePath", absolutePath).Info("Mounting new filesystem")
if _, err := os.Stat(absolutePath); err != nil {
log.G(ctx).WithField("absolutePath", absolutePath).Warning("Impossible to stat the absolute path, is the filesystem mounted properly? Error: ", err)
}
return &filesystem{fsAbsoluteMountpoint: absolutePath, mountedLayers: mountedLayersMap}, nil
}

Expand Down
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
"github.com/containerd/containerd/contrib/snapshotservice"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/snapshots"
snbase "github.com/containerd/stargz-snapshotter/snapshot"
"github.com/sirupsen/logrus"

Expand Down Expand Up @@ -74,9 +75,15 @@ func main() {
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to configure filesystem")
}
rs, err := snbase.NewSnapshotter(ctx, filepath.Join(*rootDir, "snapshotter"), fs, snbase.AsynchronousRemove)
var rs snapshots.Snapshotter
rs, err = snbase.NewSnapshotter(ctx, filepath.Join(*rootDir, "snapshotter"), fs, snbase.AsynchronousRemove)
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to configure snapshotter")
log.G(ctx).WithError(err).Warning("failed to configure snapshotter using the previous configuration")
os.RemoveAll(filepath.Join(*rootDir, "snapshotter"))
rs, err = snbase.NewSnapshotter(ctx, filepath.Join(*rootDir, "snapshotter"), fs, snbase.AsynchronousRemove)
if err != nil {
log.G(ctx).WithError(err).Fatalf("failed to configure snapshotter starting from a clean configuration")
}
}
defer func() {
log.G(ctx).Debug("Closing the snapshotter")
Expand Down

0 comments on commit 41cf87a

Please sign in to comment.