@@ -30,6 +30,7 @@ import (
3030
3131 "github.com/containerd/containerd/mount"
3232 "github.com/containerd/containerd/pkg/testutil"
33+ "github.com/containerd/containerd/plugin"
3334 "github.com/containerd/containerd/snapshots"
3435 "github.com/containerd/containerd/snapshots/testsuite"
3536 "github.com/containerd/continuity/testutil/loopback"
@@ -66,27 +67,31 @@ func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshots.Snap
6667 // sync after a mkfs on the loopback before trying to mount the device
6768 unix .Sync ()
6869
70+ var snapshotter snapshots.Snapshotter
6971 for i := 0 ; i < 5 ; i ++ {
7072 if out , err := exec .Command ("mount" , loop .Device , root ).CombinedOutput (); err != nil {
7173 loop .Close ()
7274 return nil , nil , errors .Wrapf (err , "failed to mount device %s (out: %q)" , loop .Device , out )
7375 }
74- var stat unix.Statfs_t
75- if err := unix .Statfs (root , & stat ); err != nil {
76- unix .Unmount (root , 0 )
77- return nil , nil , errors .Wrapf (err , "unable to statfs btrfs mount %s" , root )
76+
77+ if i > 0 {
78+ time .Sleep (10 * time .Duration (i ) * time .Millisecond )
7879 }
79- if stat .Type == unix .BTRFS_SUPER_MAGIC {
80+
81+ snapshotter , err = NewSnapshotter (root )
82+ if err == nil {
8083 break
84+ } else if errors .Cause (err ) != plugin .ErrSkipPlugin {
85+ return nil , nil , err
8186 }
87+
88+ t .Logf ("Attempt %d to create btrfs snapshotter failed: %#v" , i + 1 , err )
89+
8290 // unmount and try again
8391 unix .Unmount (root , 0 )
84- time .Sleep (100 * time .Millisecond )
8592 }
86- snapshotter , err := NewSnapshotter (root )
87- if err != nil {
88- loop .Close ()
89- return nil , nil , errors .Wrap (err , "failed to create new snapshotter" )
93+ if snapshotter == nil {
94+ return nil , nil , errors .Wrap (err , "failed to successfully create snapshotter after 5 attempts" )
9095 }
9196
9297 return snapshotter , func () error {
0 commit comments