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

Commit 41cf87a

Browse files
committed
make sure that the snapshotter can start even from an unknow state
1 parent 0ece4bc commit 41cf87a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

cvmfs/cvmfs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ func NewFilesystem(ctx context.Context, root string, config *Config) (snapshot.F
4747
absolutePath = config.AbsoluteMountpoint
4848
}
4949
log.G(ctx).WithField("root", root).WithField("absolutePath", absolutePath).Info("Mounting new filesystem")
50+
if _, err := os.Stat(absolutePath); err != nil {
51+
log.G(ctx).WithField("absolutePath", absolutePath).Warning("Impossible to stat the absolute path, is the filesystem mounted properly? Error: ", err)
52+
}
5053
return &filesystem{fsAbsoluteMountpoint: absolutePath, mountedLayers: mountedLayersMap}, nil
5154
}
5255

main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
2828
"github.com/containerd/containerd/contrib/snapshotservice"
2929
"github.com/containerd/containerd/log"
30+
"github.com/containerd/containerd/snapshots"
3031
snbase "github.com/containerd/stargz-snapshotter/snapshot"
3132
"github.com/sirupsen/logrus"
3233

@@ -74,9 +75,15 @@ func main() {
7475
if err != nil {
7576
log.G(ctx).WithError(err).Fatalf("failed to configure filesystem")
7677
}
77-
rs, err := snbase.NewSnapshotter(ctx, filepath.Join(*rootDir, "snapshotter"), fs, snbase.AsynchronousRemove)
78+
var rs snapshots.Snapshotter
79+
rs, err = snbase.NewSnapshotter(ctx, filepath.Join(*rootDir, "snapshotter"), fs, snbase.AsynchronousRemove)
7880
if err != nil {
79-
log.G(ctx).WithError(err).Fatalf("failed to configure snapshotter")
81+
log.G(ctx).WithError(err).Warning("failed to configure snapshotter using the previous configuration")
82+
os.RemoveAll(filepath.Join(*rootDir, "snapshotter"))
83+
rs, err = snbase.NewSnapshotter(ctx, filepath.Join(*rootDir, "snapshotter"), fs, snbase.AsynchronousRemove)
84+
if err != nil {
85+
log.G(ctx).WithError(err).Fatalf("failed to configure snapshotter starting from a clean configuration")
86+
}
8087
}
8188
defer func() {
8289
log.G(ctx).Debug("Closing the snapshotter")

0 commit comments

Comments
 (0)