enable native (formerly naive) snapshotter by default

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2018-04-02 13:29:19 +09:00
parent bf5112e8ec
commit 83e35b3d3a
7 changed files with 19 additions and 18 deletions

View File

@ -20,6 +20,7 @@ import (
_ "github.com/containerd/aufs" _ "github.com/containerd/aufs"
_ "github.com/containerd/containerd/linux" _ "github.com/containerd/containerd/linux"
_ "github.com/containerd/containerd/metrics/cgroups" _ "github.com/containerd/containerd/metrics/cgroups"
_ "github.com/containerd/containerd/snapshots/native"
_ "github.com/containerd/containerd/snapshots/overlay" _ "github.com/containerd/containerd/snapshots/overlay"
_ "github.com/containerd/zfs" _ "github.com/containerd/zfs"
) )

View File

@ -19,5 +19,5 @@
package main package main
import ( import (
_ "github.com/containerd/containerd/snapshots/naive" _ "github.com/containerd/containerd/snapshots/native"
) )

View File

@ -39,7 +39,7 @@ import (
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshots/naive" "github.com/containerd/containerd/snapshots/native"
"github.com/gogo/protobuf/types" "github.com/gogo/protobuf/types"
digest "github.com/opencontainers/go-digest" digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@ -55,7 +55,7 @@ func testDB(t *testing.T) (context.Context, *DB, func()) {
t.Fatal(err) t.Fatal(err)
} }
snapshotter, err := naive.NewSnapshotter(filepath.Join(dirname, "naive")) snapshotter, err := native.NewSnapshotter(filepath.Join(dirname, "native"))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -70,7 +70,7 @@ func testDB(t *testing.T) (context.Context, *DB, func()) {
t.Fatal(err) t.Fatal(err)
} }
db := NewDB(bdb, cs, map[string]snapshots.Snapshotter{"naive": snapshotter}) db := NewDB(bdb, cs, map[string]snapshots.Snapshotter{"native": snapshotter})
if err := db.Init(ctx); err != nil { if err := db.Init(ctx); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -544,7 +544,7 @@ func create(obj object, tx *bolt.Tx, is images.Store, cs content.Store, sn snaps
node = &gc.Node{ node = &gc.Node{
Type: ResourceSnapshot, Type: ResourceSnapshot,
Namespace: namespace, Namespace: namespace,
Key: fmt.Sprintf("naive/%s", v.key), Key: fmt.Sprintf("native/%s", v.key),
} }
} }
case testImage: case testImage:
@ -563,7 +563,7 @@ func create(obj object, tx *bolt.Tx, is images.Store, cs content.Store, sn snaps
container := containers.Container{ container := containers.Container{
ID: v.id, ID: v.id,
SnapshotKey: v.snapshot, SnapshotKey: v.snapshot,
Snapshotter: "naive", Snapshotter: "native",
Labels: obj.labels, Labels: obj.labels,
Runtime: containers.RuntimeInfo{ Runtime: containers.RuntimeInfo{
@ -658,7 +658,7 @@ func newStores(t testing.TB) (*DB, content.Store, snapshots.Snapshotter, func())
t.Fatal(err) t.Fatal(err)
} }
nsn, err := naive.NewSnapshotter(filepath.Join(td, "snapshots")) nsn, err := native.NewSnapshotter(filepath.Join(td, "snapshots"))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -668,9 +668,9 @@ func newStores(t testing.TB) (*DB, content.Store, snapshots.Snapshotter, func())
t.Fatal(err) t.Fatal(err)
} }
mdb := NewDB(db, lcs, map[string]snapshots.Snapshotter{"naive": nsn}) mdb := NewDB(db, lcs, map[string]snapshots.Snapshotter{"native": nsn})
return mdb, mdb.ContentStore(), mdb.Snapshotter("naive"), func() { return mdb, mdb.ContentStore(), mdb.Snapshotter("native"), func() {
os.RemoveAll(td) os.RemoveAll(td)
} }
} }

View File

@ -25,17 +25,17 @@ import (
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
"github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshots/naive" "github.com/containerd/containerd/snapshots/native"
"github.com/containerd/containerd/snapshots/testsuite" "github.com/containerd/containerd/snapshots/testsuite"
"github.com/containerd/containerd/testutil" "github.com/containerd/containerd/testutil"
) )
func newTestSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) { func newTestSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) {
naiveRoot := filepath.Join(root, "naive") nativeRoot := filepath.Join(root, "native")
if err := os.Mkdir(naiveRoot, 0770); err != nil { if err := os.Mkdir(nativeRoot, 0770); err != nil {
return nil, nil, err return nil, nil, err
} }
snapshotter, err := naive.NewSnapshotter(naiveRoot) snapshotter, err := native.NewSnapshotter(nativeRoot)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -45,7 +45,7 @@ func newTestSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter
return nil, nil, err return nil, nil, err
} }
sn := NewDB(db, nil, map[string]snapshots.Snapshotter{"naive": snapshotter}).Snapshotter("naive") sn := NewDB(db, nil, map[string]snapshots.Snapshotter{"native": snapshotter}).Snapshotter("native")
return sn, func() error { return sn, func() error {
if err := sn.Close(); err != nil { if err := sn.Close(); err != nil {

View File

@ -14,7 +14,7 @@
limitations under the License. limitations under the License.
*/ */
package naive package native
import ( import (
"context" "context"
@ -35,7 +35,7 @@ import (
func init() { func init() {
plugin.Register(&plugin.Registration{ plugin.Register(&plugin.Registration{
Type: plugin.SnapshotPlugin, Type: plugin.SnapshotPlugin,
ID: "naive", ID: "native",
InitFn: func(ic *plugin.InitContext) (interface{}, error) { InitFn: func(ic *plugin.InitContext) (interface{}, error) {
ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec()) ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
return NewSnapshotter(ic.Root) return NewSnapshotter(ic.Root)

View File

@ -14,7 +14,7 @@
limitations under the License. limitations under the License.
*/ */
package naive package native
import ( import (
"context" "context"

View File

@ -22,5 +22,5 @@ const (
// DefaultSnapshotter will set the default snapshotter for the platform. // DefaultSnapshotter will set the default snapshotter for the platform.
// This will be based on the client compilation target, so take that into // This will be based on the client compilation target, so take that into
// account when choosing this value. // account when choosing this value.
DefaultSnapshotter = "naive" DefaultSnapshotter = "native"
) )