Merge pull request #1797 from jessvalarezo/rename-packages

rename snapshot->snapshots packages, add aliases
This commit is contained in:
Derek McGowan 2017-11-29 17:53:11 -08:00 committed by GitHub
commit 96ca9738ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 508 additions and 503 deletions

View File

@ -2793,7 +2793,7 @@ file {
syntax: "proto3" syntax: "proto3"
} }
file { file {
name: "github.com/containerd/containerd/api/services/snapshot/v1/snapshots.proto" name: "github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto"
package: "containerd.services.snapshots.v1" package: "containerd.services.snapshots.v1"
dependency: "gogoproto/gogo.proto" dependency: "gogoproto/gogo.proto"
dependency: "google/protobuf/empty.proto" dependency: "google/protobuf/empty.proto"
@ -3317,7 +3317,7 @@ file {
} }
} }
options { options {
go_package: "github.com/containerd/containerd/api/services/snapshot/v1;snapshot" go_package: "github.com/containerd/containerd/api/services/snapshots/v1;snapshots"
} }
weak_dependency: 0 weak_dependency: 0
syntax: "proto3" syntax: "proto3"

View File

@ -1,11 +1,11 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: github.com/containerd/containerd/api/services/snapshot/v1/snapshots.proto // source: github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto
/* /*
Package snapshot is a generated protocol buffer package. Package snapshots is a generated protocol buffer package.
It is generated from these files: It is generated from these files:
github.com/containerd/containerd/api/services/snapshot/v1/snapshots.proto github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto
It has these top-level messages: It has these top-level messages:
PrepareSnapshotRequest PrepareSnapshotRequest
@ -26,7 +26,7 @@
UsageRequest UsageRequest
UsageResponse UsageResponse
*/ */
package snapshot package snapshots
import proto "github.com/gogo/protobuf/proto" import proto "github.com/gogo/protobuf/proto"
import fmt "fmt" import fmt "fmt"
@ -651,7 +651,7 @@ var _Snapshots_serviceDesc = grpc.ServiceDesc{
ServerStreams: true, ServerStreams: true,
}, },
}, },
Metadata: "github.com/containerd/containerd/api/services/snapshot/v1/snapshots.proto", Metadata: "github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto",
} }
func (m *PrepareSnapshotRequest) Marshal() (dAtA []byte, err error) { func (m *PrepareSnapshotRequest) Marshal() (dAtA []byte, err error) {
@ -4194,72 +4194,72 @@ var (
) )
func init() { func init() {
proto.RegisterFile("github.com/containerd/containerd/api/services/snapshot/v1/snapshots.proto", fileDescriptorSnapshots) proto.RegisterFile("github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto", fileDescriptorSnapshots)
} }
var fileDescriptorSnapshots = []byte{ var fileDescriptorSnapshots = []byte{
// 1006 bytes of a gzipped FileDescriptorProto // 1007 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0x1a, 0x47, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0x1a, 0x47,
0x14, 0x67, 0x60, 0x8d, 0xe3, 0x87, 0xed, 0xd2, 0x09, 0x26, 0x68, 0x5b, 0xe1, 0x15, 0x87, 0xca, 0x14, 0x67, 0x60, 0x8d, 0xe3, 0x87, 0xed, 0xd2, 0x09, 0x26, 0x68, 0x5b, 0xe1, 0x15, 0x87, 0xca,
0xea, 0x61, 0x37, 0xa1, 0x6a, 0xe2, 0xc4, 0x97, 0x02, 0xa1, 0x15, 0x71, 0xec, 0x54, 0x1b, 0xdb, 0xea, 0x61, 0x37, 0xa1, 0x6a, 0xe2, 0xc4, 0x97, 0x62, 0x4c, 0x2b, 0xec, 0xd8, 0xa9, 0x36, 0xb6,
0x89, 0xd3, 0x48, 0xd1, 0x1a, 0xc6, 0x78, 0x05, 0xbb, 0x4b, 0x99, 0x81, 0x88, 0x56, 0xaa, 0x7a, 0x13, 0xa7, 0x55, 0xa3, 0x35, 0x8c, 0xf1, 0x0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0x56, 0x20, 0x3f, 0x8f, 0x1c, 0xc5, 0xc5, 0x45, 0xfa, 0xe4, 0x8b, 0x5e, 0x6c, 0x4d, 0xff, 0xcf, 0xb9, 0xd1, 0x9b, 0x3c, 0x8f, 0x1c, 0xc7, 0xc5, 0x55, 0xfa,
0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xed, 0x58, 0xc4, 0xcf, 0xc1, 0x0e, 0x00, 0x00, 0xe8, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xa0, 0xb2, 0xda, 0xc4, 0x0e, 0x00, 0x00,
} }

View File

@ -8,7 +8,7 @@ import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto"; import "google/protobuf/timestamp.proto";
import "github.com/containerd/containerd/api/types/mount.proto"; import "github.com/containerd/containerd/api/types/mount.proto";
option go_package = "github.com/containerd/containerd/api/services/snapshot/v1;snapshot"; option go_package = "github.com/containerd/containerd/api/services/snapshots/v1;snapshots";
// Snapshot service manages snapshots // Snapshot service manages snapshots
service Snapshots { service Snapshots {

View File

@ -17,7 +17,7 @@ import (
imagesapi "github.com/containerd/containerd/api/services/images/v1" imagesapi "github.com/containerd/containerd/api/services/images/v1"
introspectionapi "github.com/containerd/containerd/api/services/introspection/v1" introspectionapi "github.com/containerd/containerd/api/services/introspection/v1"
namespacesapi "github.com/containerd/containerd/api/services/namespaces/v1" namespacesapi "github.com/containerd/containerd/api/services/namespaces/v1"
snapshotapi "github.com/containerd/containerd/api/services/snapshot/v1" snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
"github.com/containerd/containerd/api/services/tasks/v1" "github.com/containerd/containerd/api/services/tasks/v1"
versionservice "github.com/containerd/containerd/api/services/version/v1" versionservice "github.com/containerd/containerd/api/services/version/v1"
"github.com/containerd/containerd/containers" "github.com/containerd/containerd/containers"
@ -33,7 +33,7 @@ import (
"github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/remotes/docker"
"github.com/containerd/containerd/remotes/docker/schema1" "github.com/containerd/containerd/remotes/docker/schema1"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/containerd/typeurl" "github.com/containerd/typeurl"
ptypes "github.com/gogo/protobuf/types" ptypes "github.com/gogo/protobuf/types"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@ -435,8 +435,8 @@ func (c *Client) ContentStore() content.Store {
} }
// SnapshotService returns the underlying snapshotter for the provided snapshotter name // SnapshotService returns the underlying snapshotter for the provided snapshotter name
func (c *Client) SnapshotService(snapshotterName string) snapshot.Snapshotter { func (c *Client) SnapshotService(snapshotterName string) snapshots.Snapshotter {
return NewSnapshotterFromClient(snapshotapi.NewSnapshotsClient(c.conn), snapshotterName) return NewSnapshotterFromClient(snapshotsapi.NewSnapshotsClient(c.conn), snapshotterName)
} }
// TaskService returns the underlying TasksClient // TaskService returns the underlying TasksClient

View File

@ -13,7 +13,7 @@ import (
_ "github.com/containerd/containerd/services/introspection" _ "github.com/containerd/containerd/services/introspection"
_ "github.com/containerd/containerd/services/leases" _ "github.com/containerd/containerd/services/leases"
_ "github.com/containerd/containerd/services/namespaces" _ "github.com/containerd/containerd/services/namespaces"
_ "github.com/containerd/containerd/services/snapshot" _ "github.com/containerd/containerd/services/snapshots"
_ "github.com/containerd/containerd/services/tasks" _ "github.com/containerd/containerd/services/tasks"
_ "github.com/containerd/containerd/services/version" _ "github.com/containerd/containerd/services/version"
) )

View File

@ -2,4 +2,4 @@
package main package main
import _ "github.com/containerd/containerd/snapshot/btrfs" import _ "github.com/containerd/containerd/snapshots/btrfs"

View File

@ -3,5 +3,5 @@ package main
import ( import (
_ "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/snapshot/overlay" _ "github.com/containerd/containerd/snapshots/overlay"
) )

View File

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

View File

@ -1,6 +1,6 @@
package main package main
import ( import (
_ "github.com/containerd/containerd/snapshot/windows" _ "github.com/containerd/containerd/snapshots/windows"
_ "github.com/containerd/containerd/windows" _ "github.com/containerd/containerd/windows"
) )

View File

@ -18,7 +18,7 @@ import (
var Command = cli.Command{ var Command = cli.Command{
Name: "containers", Name: "containers",
Usage: "manage containers", Usage: "manage containers",
Aliases: []string{"c"}, Aliases: []string{"c", "container"},
Subcommands: []cli.Command{ Subcommands: []cli.Command{
deleteCommand, deleteCommand,
infoCommand, infoCommand,

View File

@ -16,6 +16,7 @@ import (
// Command is the cli command for displaying containerd events // Command is the cli command for displaying containerd events
var Command = cli.Command{ var Command = cli.Command{
Name: "events", Name: "events",
Aliases: []string{"event"},
Usage: "display containerd events", Usage: "display containerd events",
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
client, ctx, cancel, err := commands.NewClient(context) client, ctx, cancel, err := commands.NewClient(context)

View File

@ -20,6 +20,7 @@ import (
// Command is the cli command for managing images // Command is the cli command for managing images
var Command = cli.Command{ var Command = cli.Command{
Name: "images", Name: "images",
Aliases: []string{"image"},
Usage: "manage images", Usage: "manage images",
Subcommands: cli.Commands{ Subcommands: cli.Commands{
checkCommand, checkCommand,

View File

@ -17,6 +17,7 @@ import (
// Command is the cli command for managing namespaces // Command is the cli command for managing namespaces
var Command = cli.Command{ var Command = cli.Command{
Name: "namespaces", Name: "namespaces",
Aliases: []string{"namespace"},
Usage: "manage namespaces", Usage: "manage namespaces",
Subcommands: cli.Commands{ Subcommands: cli.Commands{
createCommand, createCommand,

View File

@ -19,6 +19,7 @@ import (
// Command is a cli command that outputs plugin information // Command is a cli command that outputs plugin information
var Command = cli.Command{ var Command = cli.Command{
Name: "plugins", Name: "plugins",
Aliases: []string{"plugin"},
Usage: "provides information about containerd plugins", Usage: "provides information about containerd plugins",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{ cli.BoolFlag{

View File

@ -1,4 +1,4 @@
package snapshot package snapshots
import ( import (
gocontext "context" gocontext "context"
@ -11,7 +11,7 @@ import (
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/progress" "github.com/containerd/containerd/progress"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
digest "github.com/opencontainers/go-digest" digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/urfave/cli" "github.com/urfave/cli"
@ -19,7 +19,8 @@ import (
// Command is the cli command for managing snapshots // Command is the cli command for managing snapshots
var Command = cli.Command{ var Command = cli.Command{
Name: "snapshot", Name: "snapshots",
Aliases: []string{"snapshot"},
Usage: "manage snapshots", Usage: "manage snapshots",
Flags: commands.SnapshotterFlags, Flags: commands.SnapshotterFlags,
Subcommands: cli.Commands{ Subcommands: cli.Commands{
@ -52,7 +53,7 @@ var listCommand = cli.Command{
tw = tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0) tw = tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0)
) )
fmt.Fprintln(tw, "KEY\tPARENT\tKIND\t") fmt.Fprintln(tw, "KEY\tPARENT\tKIND\t")
if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshot.Info) error { if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshots.Info) error {
fmt.Fprintf(tw, "%v\t%v\t%v\t\n", fmt.Fprintf(tw, "%v\t%v\t%v\t\n",
info.Name, info.Name,
info.Parent, info.Parent,
@ -98,7 +99,7 @@ var usageCommand = cli.Command{
) )
fmt.Fprintln(tw, "KEY\tSIZE\tINODES\t") fmt.Fprintln(tw, "KEY\tSIZE\tINODES\t")
if context.NArg() == 0 { if context.NArg() == 0 {
if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshot.Info) error { if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshots.Info) error {
usage, err := snapshotter.Usage(ctx, info.Name) usage, err := snapshotter.Usage(ctx, info.Name)
if err != nil { if err != nil {
return err return err
@ -289,7 +290,7 @@ var treeCommand = cli.Command{
tree = make(map[string]*snapshotTreeNode) tree = make(map[string]*snapshotTreeNode)
) )
if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshot.Info) error { if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshots.Info) error {
// Get or create node and add node details // Get or create node and add node details
node := getOrCreateTreeNode(info.Name, tree) node := getOrCreateTreeNode(info.Name, tree)
if info.Parent != "" { if info.Parent != "" {
@ -351,7 +352,7 @@ var setLabelCommand = cli.Command{
snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) snapshotter := client.SnapshotService(context.GlobalString("snapshotter"))
info := snapshot.Info{ info := snapshots.Info{
Name: key, Name: key,
Labels: map[string]string{}, Labels: map[string]string{},
} }

View File

@ -14,7 +14,7 @@ type resizer interface {
var Command = cli.Command{ var Command = cli.Command{
Name: "tasks", Name: "tasks",
Usage: "manage tasks", Usage: "manage tasks",
Aliases: []string{"t"}, Aliases: []string{"t", "task"},
Subcommands: []cli.Command{ Subcommands: []cli.Command{
attachCommand, attachCommand,
checkpointCommand, checkpointCommand,

View File

@ -14,7 +14,7 @@ import (
"github.com/containerd/containerd/cmd/ctr/commands/plugins" "github.com/containerd/containerd/cmd/ctr/commands/plugins"
"github.com/containerd/containerd/cmd/ctr/commands/pprof" "github.com/containerd/containerd/cmd/ctr/commands/pprof"
"github.com/containerd/containerd/cmd/ctr/commands/run" "github.com/containerd/containerd/cmd/ctr/commands/run"
"github.com/containerd/containerd/cmd/ctr/commands/snapshot" "github.com/containerd/containerd/cmd/ctr/commands/snapshots"
"github.com/containerd/containerd/cmd/ctr/commands/tasks" "github.com/containerd/containerd/cmd/ctr/commands/tasks"
versionCmd "github.com/containerd/containerd/cmd/ctr/commands/version" versionCmd "github.com/containerd/containerd/cmd/ctr/commands/version"
"github.com/containerd/containerd/defaults" "github.com/containerd/containerd/defaults"
@ -84,7 +84,7 @@ containerd CLI
namespacesCmd.Command, namespacesCmd.Command,
pprof.Command, pprof.Command,
run.Command, run.Command,
snapshot.Command, snapshots.Command,
tasks.Command, tasks.Command,
}, extraCmds...) }, extraCmds...)
app.Before = func(context *cli.Context) error { app.Before = func(context *cli.Context) error {

View File

@ -9,7 +9,7 @@ import (
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
"github.com/containerd/containerd/platforms" "github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/rootfs" "github.com/containerd/containerd/rootfs"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
digest "github.com/opencontainers/go-digest" digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/identity" "github.com/opencontainers/image-spec/identity"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@ -112,7 +112,7 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string) error {
"containerd.io/uncompressed": layer.Diff.Digest.String(), "containerd.io/uncompressed": layer.Diff.Digest.String(),
} }
unpacked, err = rootfs.ApplyLayer(ctx, layer, chain, sn, a, snapshot.WithLabels(labels)) unpacked, err = rootfs.ApplyLayer(ctx, layer, chain, sn, a, snapshots.WithLabels(labels))
if err != nil { if err != nil {
return err return err
} }

View File

@ -11,7 +11,7 @@ import (
"github.com/containerd/containerd/content" "github.com/containerd/containerd/content"
"github.com/containerd/containerd/gc" "github.com/containerd/containerd/gc"
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -60,7 +60,7 @@ type DB struct {
// NewDB creates a new metadata database using the provided // NewDB creates a new metadata database using the provided
// bolt database, content store, and snapshotters. // bolt database, content store, and snapshotters.
func NewDB(db *bolt.DB, cs content.Store, ss map[string]snapshot.Snapshotter) *DB { func NewDB(db *bolt.DB, cs content.Store, ss map[string]snapshots.Snapshotter) *DB {
m := &DB{ m := &DB{
db: db, db: db,
ss: make(map[string]*snapshotter, len(ss)), ss: make(map[string]*snapshotter, len(ss)),
@ -171,7 +171,7 @@ func (m *DB) ContentStore() content.Store {
// Snapshotter returns a namespaced content store for // Snapshotter returns a namespaced content store for
// the requested snapshotter name proxied to a snapshotter. // the requested snapshotter name proxied to a snapshotter.
func (m *DB) Snapshotter(name string) snapshot.Snapshotter { func (m *DB) Snapshotter(name string) snapshots.Snapshotter {
sn, ok := m.ss[name] sn, ok := m.ss[name]
if !ok { if !ok {
return nil return nil

View File

@ -21,8 +21,8 @@ import (
"github.com/containerd/containerd/gc" "github.com/containerd/containerd/gc"
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshot/naive" "github.com/containerd/containerd/snapshots/naive"
"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"
@ -377,7 +377,7 @@ type object struct {
labels map[string]string labels map[string]string
} }
func create(obj object, tx *bolt.Tx, cs content.Store, sn snapshot.Snapshotter) (*gc.Node, error) { func create(obj object, tx *bolt.Tx, cs content.Store, sn snapshots.Snapshotter) (*gc.Node, error) {
var ( var (
node *gc.Node node *gc.Node
namespace = "test" namespace = "test"
@ -408,7 +408,7 @@ func create(obj object, tx *bolt.Tx, cs content.Store, sn snapshot.Snapshotter)
case testSnapshot: case testSnapshot:
ctx := WithTransactionContext(ctx, tx) ctx := WithTransactionContext(ctx, tx)
if v.active { if v.active {
_, err := sn.Prepare(ctx, v.key, v.parent, snapshot.WithLabels(obj.labels)) _, err := sn.Prepare(ctx, v.key, v.parent, snapshots.WithLabels(obj.labels))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -418,7 +418,7 @@ func create(obj object, tx *bolt.Tx, cs content.Store, sn snapshot.Snapshotter)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if err := sn.Commit(ctx, v.key, akey, snapshot.WithLabels(obj.labels)); err != nil { if err := sn.Commit(ctx, v.key, akey, snapshots.WithLabels(obj.labels)); err != nil {
return nil, err return nil, err
} }
} }
@ -528,7 +528,7 @@ type testContainer struct {
snapshot string snapshot string
} }
func newStores(t testing.TB) (*DB, content.Store, snapshot.Snapshotter, func()) { func newStores(t testing.TB) (*DB, content.Store, snapshots.Snapshotter, func()) {
td, err := ioutil.TempDir("", "gc-test-") td, err := ioutil.TempDir("", "gc-test-")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -548,7 +548,7 @@ func newStores(t testing.TB) (*DB, content.Store, snapshot.Snapshotter, func())
t.Fatal(err) t.Fatal(err)
} }
mdb := NewDB(db, lcs, map[string]snapshot.Snapshotter{"naive": nsn}) mdb := NewDB(db, lcs, map[string]snapshots.Snapshotter{"naive": nsn})
return mdb, mdb.ContentStore(), mdb.Snapshotter("naive"), func() { return mdb, mdb.ContentStore(), mdb.Snapshotter("naive"), func() {
os.RemoveAll(td) os.RemoveAll(td)

View File

@ -14,12 +14,12 @@ import (
"github.com/containerd/containerd/metadata/boltutil" "github.com/containerd/containerd/metadata/boltutil"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
type snapshotter struct { type snapshotter struct {
snapshot.Snapshotter snapshots.Snapshotter
name string name string
db *DB db *DB
l sync.RWMutex l sync.RWMutex
@ -27,7 +27,7 @@ type snapshotter struct {
// newSnapshotter returns a new Snapshotter which namespaces the given snapshot // newSnapshotter returns a new Snapshotter which namespaces the given snapshot
// using the provided name and database. // using the provided name and database.
func newSnapshotter(db *DB, name string, sn snapshot.Snapshotter) *snapshotter { func newSnapshotter(db *DB, name string, sn snapshots.Snapshotter) *snapshotter {
return &snapshotter{ return &snapshotter{
Snapshotter: sn, Snapshotter: sn,
name: name, name: name,
@ -75,15 +75,15 @@ func (s *snapshotter) resolveKey(ctx context.Context, key string) (string, error
return id, nil return id, nil
} }
func (s *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { func (s *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) {
ns, err := namespaces.NamespaceRequired(ctx) ns, err := namespaces.NamespaceRequired(ctx)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
var ( var (
bkey string bkey string
local = snapshot.Info{ local = snapshots.Info{
Name: key, Name: key,
} }
) )
@ -108,33 +108,33 @@ func (s *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, erro
return nil return nil
}); err != nil { }); err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
info, err := s.Snapshotter.Stat(ctx, bkey) info, err := s.Snapshotter.Stat(ctx, bkey)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
return overlayInfo(info, local), nil return overlayInfo(info, local), nil
} }
func (s *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { func (s *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
s.l.RLock() s.l.RLock()
defer s.l.RUnlock() defer s.l.RUnlock()
ns, err := namespaces.NamespaceRequired(ctx) ns, err := namespaces.NamespaceRequired(ctx)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
if info.Name == "" { if info.Name == "" {
return snapshot.Info{}, errors.Wrap(errdefs.ErrInvalidArgument, "") return snapshots.Info{}, errors.Wrap(errdefs.ErrInvalidArgument, "")
} }
var ( var (
bkey string bkey string
local = snapshot.Info{ local = snapshots.Info{
Name: info.Name, Name: info.Name,
} }
) )
@ -195,18 +195,18 @@ func (s *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths
return nil return nil
}); err != nil { }); err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
info, err = s.Snapshotter.Stat(ctx, bkey) info, err = s.Snapshotter.Stat(ctx, bkey)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
return overlayInfo(info, local), nil return overlayInfo(info, local), nil
} }
func overlayInfo(info, overlay snapshot.Info) snapshot.Info { func overlayInfo(info, overlay snapshots.Info) snapshots.Info {
// Merge info // Merge info
info.Name = overlay.Name info.Name = overlay.Name
info.Created = overlay.Created info.Created = overlay.Created
@ -222,10 +222,10 @@ func overlayInfo(info, overlay snapshot.Info) snapshot.Info {
return info return info
} }
func (s *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { func (s *snapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) {
bkey, err := s.resolveKey(ctx, key) bkey, err := s.resolveKey(ctx, key)
if err != nil { if err != nil {
return snapshot.Usage{}, err return snapshots.Usage{}, err
} }
return s.Snapshotter.Usage(ctx, bkey) return s.Snapshotter.Usage(ctx, bkey)
} }
@ -238,15 +238,15 @@ func (s *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er
return s.Snapshotter.Mounts(ctx, bkey) return s.Snapshotter.Mounts(ctx, bkey)
} }
func (s *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (s *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
return s.createSnapshot(ctx, key, parent, false, opts) return s.createSnapshot(ctx, key, parent, false, opts)
} }
func (s *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (s *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
return s.createSnapshot(ctx, key, parent, true, opts) return s.createSnapshot(ctx, key, parent, true, opts)
} }
func (s *snapshotter) createSnapshot(ctx context.Context, key, parent string, readonly bool, opts []snapshot.Opt) ([]mount.Mount, error) { func (s *snapshotter) createSnapshot(ctx context.Context, key, parent string, readonly bool, opts []snapshots.Opt) ([]mount.Mount, error) {
s.l.RLock() s.l.RLock()
defer s.l.RUnlock() defer s.l.RUnlock()
@ -255,7 +255,7 @@ func (s *snapshotter) createSnapshot(ctx context.Context, key, parent string, re
return nil, err return nil, err
} }
var base snapshot.Info var base snapshots.Info
for _, opt := range opts { for _, opt := range opts {
if err := opt(&base); err != nil { if err := opt(&base); err != nil {
return nil, err return nil, err
@ -336,7 +336,7 @@ func (s *snapshotter) createSnapshot(ctx context.Context, key, parent string, re
return m, nil return m, nil
} }
func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
s.l.RLock() s.l.RLock()
defer s.l.RUnlock() defer s.l.RUnlock()
@ -345,7 +345,7 @@ func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
return err return err
} }
var base snapshot.Info var base snapshots.Info
for _, opt := range opts { for _, opt := range opts {
if err := opt(&base); err != nil { if err := opt(&base); err != nil {
return err return err
@ -493,10 +493,10 @@ func (s *snapshotter) Remove(ctx context.Context, key string) error {
type infoPair struct { type infoPair struct {
bkey string bkey string
info snapshot.Info info snapshots.Info
} }
func (s *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { func (s *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
ns, err := namespaces.NamespaceRequired(ctx) ns, err := namespaces.NamespaceRequired(ctx)
if err != nil { if err != nil {
return err return err
@ -533,7 +533,7 @@ func (s *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho
pair := infoPair{ pair := infoPair{
bkey: string(sbkt.Get(bucketKeyName)), bkey: string(sbkt.Get(bucketKeyName)),
info: snapshot.Info{ info: snapshots.Info{
Name: string(k), Name: string(k),
Parent: string(sbkt.Get(bucketKeyParent)), Parent: string(sbkt.Get(bucketKeyParent)),
}, },
@ -586,7 +586,7 @@ func (s *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho
return nil return nil
} }
func validateSnapshot(info *snapshot.Info) error { func validateSnapshot(info *snapshots.Info) error {
for k, v := range info.Labels { for k, v := range info.Labels {
if err := labels.Validate(k, v); err != nil { if err := labels.Validate(k, v); err != nil {
return errors.Wrapf(err, "info.Labels") return errors.Wrapf(err, "info.Labels")
@ -670,7 +670,7 @@ func (s *snapshotter) garbageCollect(ctx context.Context) (d time.Duration, err
} }
type treeNode struct { type treeNode struct {
info snapshot.Info info snapshots.Info
remove bool remove bool
children []*treeNode children []*treeNode
} }
@ -679,7 +679,7 @@ func (s *snapshotter) walkTree(ctx context.Context, seen map[string]struct{}) ([
roots := []*treeNode{} roots := []*treeNode{}
nodes := map[string]*treeNode{} nodes := map[string]*treeNode{}
if err := s.Snapshotter.Walk(ctx, func(ctx context.Context, info snapshot.Info) error { if err := s.Snapshotter.Walk(ctx, func(ctx context.Context, info snapshots.Info) error {
_, isSeen := seen[info.Name] _, isSeen := seen[info.Name]
node, ok := nodes[info.Name] node, ok := nodes[info.Name]
if !ok { if !ok {

View File

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

View File

@ -4,13 +4,13 @@ import (
"context" "context"
"github.com/containerd/containerd/content" "github.com/containerd/containerd/content"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// Client interface used by SpecOpt // Client interface used by SpecOpt
type Client interface { type Client interface {
SnapshotService(snapshotterName string) snapshot.Snapshotter SnapshotService(snapshotterName string) snapshots.Snapshotter
} }
// Image interface used by some SpecOpt to query image configuration // Image interface used by some SpecOpt to query image configuration

View File

@ -9,7 +9,7 @@ import (
"github.com/containerd/containerd/diff" "github.com/containerd/containerd/diff"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/identity" "github.com/opencontainers/image-spec/identity"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@ -30,7 +30,7 @@ type Layer struct {
// The returned result is a chain id digest representing all the applied layers. // The returned result is a chain id digest representing all the applied layers.
// Layers are applied in order they are given, making the first layer the // Layers are applied in order they are given, making the first layer the
// bottom-most layer in the layer chain. // bottom-most layer in the layer chain.
func ApplyLayers(ctx context.Context, layers []Layer, sn snapshot.Snapshotter, a diff.Differ) (digest.Digest, error) { func ApplyLayers(ctx context.Context, layers []Layer, sn snapshots.Snapshotter, a diff.Differ) (digest.Digest, error) {
var chain []digest.Digest var chain []digest.Digest
for _, layer := range layers { for _, layer := range layers {
if _, err := ApplyLayer(ctx, layer, chain, sn, a); err != nil { if _, err := ApplyLayer(ctx, layer, chain, sn, a); err != nil {
@ -46,7 +46,7 @@ func ApplyLayers(ctx context.Context, layers []Layer, sn snapshot.Snapshotter, a
// ApplyLayer applies a single layer on top of the given provided layer chain, // ApplyLayer applies a single layer on top of the given provided layer chain,
// using the provided snapshotter and applier. If the layer was unpacked true // using the provided snapshotter and applier. If the layer was unpacked true
// is returned, if the layer already exists false is returned. // is returned, if the layer already exists false is returned.
func ApplyLayer(ctx context.Context, layer Layer, chain []digest.Digest, sn snapshot.Snapshotter, a diff.Differ, opts ...snapshot.Opt) (bool, error) { func ApplyLayer(ctx context.Context, layer Layer, chain []digest.Digest, sn snapshots.Snapshotter, a diff.Differ, opts ...snapshots.Opt) (bool, error) {
var ( var (
parent = identity.ChainID(chain) parent = identity.ChainID(chain)
chainID = identity.ChainID(append(chain, layer.Diff.Digest)) chainID = identity.ChainID(append(chain, layer.Diff.Digest))

View File

@ -5,7 +5,7 @@ import (
"github.com/containerd/containerd/diff" "github.com/containerd/containerd/diff"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -14,7 +14,7 @@ import (
// of the snapshot. A content ref is provided to track the progress of the // of the snapshot. A content ref is provided to track the progress of the
// content creation and the provided snapshotter and mount differ are used // content creation and the provided snapshotter and mount differ are used
// for calculating the diff. The descriptor for the layer diff is returned. // for calculating the diff. The descriptor for the layer diff is returned.
func Diff(ctx context.Context, snapshotID string, sn snapshot.Snapshotter, d diff.Differ, opts ...diff.Opt) (ocispec.Descriptor, error) { func Diff(ctx context.Context, snapshotID string, sn snapshots.Snapshotter, d diff.Differ, opts ...diff.Opt) (ocispec.Descriptor, error) {
info, err := sn.Stat(ctx, snapshotID) info, err := sn.Stat(ctx, snapshotID)
if err != nil { if err != nil {
return ocispec.Descriptor{}, err return ocispec.Descriptor{}, err
@ -28,7 +28,7 @@ func Diff(ctx context.Context, snapshotID string, sn snapshot.Snapshotter, d dif
defer sn.Remove(ctx, lowerKey) defer sn.Remove(ctx, lowerKey)
var upper []mount.Mount var upper []mount.Mount
if info.Kind == snapshot.KindActive { if info.Kind == snapshots.KindActive {
upper, err = sn.Mounts(ctx, snapshotID) upper, err = sn.Mounts(ctx, snapshotID)
if err != nil { if err != nil {
return ocispec.Descriptor{}, err return ocispec.Descriptor{}, err

View File

@ -8,7 +8,7 @@ import (
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
digest "github.com/opencontainers/go-digest" digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -26,7 +26,7 @@ type Mounter interface {
} }
// InitRootFS initializes the snapshot for use as a rootfs // InitRootFS initializes the snapshot for use as a rootfs
func InitRootFS(ctx context.Context, name string, parent digest.Digest, readonly bool, snapshotter snapshot.Snapshotter, mounter Mounter) ([]mount.Mount, error) { func InitRootFS(ctx context.Context, name string, parent digest.Digest, readonly bool, snapshotter snapshots.Snapshotter, mounter Mounter) ([]mount.Mount, error) {
_, err := snapshotter.Stat(ctx, name) _, err := snapshotter.Stat(ctx, name)
if err == nil { if err == nil {
return nil, errors.Errorf("rootfs already exists") return nil, errors.Errorf("rootfs already exists")
@ -51,7 +51,7 @@ func InitRootFS(ctx context.Context, name string, parent digest.Digest, readonly
return snapshotter.Prepare(ctx, name, parentS) return snapshotter.Prepare(ctx, name, parentS)
} }
func createInitLayer(ctx context.Context, parent, initName string, initFn func(string) error, snapshotter snapshot.Snapshotter, mounter Mounter) (string, error) { func createInitLayer(ctx context.Context, parent, initName string, initFn func(string) error, snapshotter snapshots.Snapshotter, mounter Mounter) (string, error) {
initS := fmt.Sprintf("%s %s", parent, initName) initS := fmt.Sprintf("%s %s", parent, initName)
if _, err := snapshotter.Stat(ctx, initS); err == nil { if _, err := snapshotter.Stat(ctx, initS); err == nil {
return initS, nil return initS, nil

View File

@ -18,7 +18,7 @@ import (
introspection "github.com/containerd/containerd/api/services/introspection/v1" introspection "github.com/containerd/containerd/api/services/introspection/v1"
leasesapi "github.com/containerd/containerd/api/services/leases/v1" leasesapi "github.com/containerd/containerd/api/services/leases/v1"
namespaces "github.com/containerd/containerd/api/services/namespaces/v1" namespaces "github.com/containerd/containerd/api/services/namespaces/v1"
snapshotapi "github.com/containerd/containerd/api/services/snapshot/v1" snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
tasks "github.com/containerd/containerd/api/services/tasks/v1" tasks "github.com/containerd/containerd/api/services/tasks/v1"
version "github.com/containerd/containerd/api/services/version/v1" version "github.com/containerd/containerd/api/services/version/v1"
"github.com/containerd/containerd/content" "github.com/containerd/containerd/content"
@ -27,7 +27,7 @@ import (
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/metadata" "github.com/containerd/containerd/metadata"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
metrics "github.com/docker/go-metrics" metrics "github.com/docker/go-metrics"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -199,7 +199,7 @@ func loadPlugins(config *Config) ([]*plugin.Registration, error) {
return nil, err return nil, err
} }
snapshotters := make(map[string]snapshot.Snapshotter) snapshotters := make(map[string]snapshots.Snapshotter)
for name, sn := range snapshottersRaw { for name, sn := range snapshottersRaw {
sn, err := sn.Instance() sn, err := sn.Instance()
if err != nil { if err != nil {
@ -207,7 +207,7 @@ func loadPlugins(config *Config) ([]*plugin.Registration, error) {
Warnf("could not use snapshotter %v in metadata plugin", name) Warnf("could not use snapshotter %v in metadata plugin", name)
continue continue
} }
snapshotters[name] = sn.(snapshot.Snapshotter) snapshotters[name] = sn.(snapshots.Snapshotter)
} }
path := filepath.Join(ic.Root, "meta.db") path := filepath.Join(ic.Root, "meta.db")
@ -249,7 +249,7 @@ func interceptor(
// No need to change the context // No need to change the context
case version.VersionServer: case version.VersionServer:
ctx = log.WithModule(ctx, "version") ctx = log.WithModule(ctx, "version")
case snapshotapi.SnapshotsServer: case snapshotsapi.SnapshotsServer:
ctx = log.WithModule(ctx, "snapshot") ctx = log.WithModule(ctx, "snapshot")
case diff.DiffServer: case diff.DiffServer:
ctx = log.WithModule(ctx, "diff") ctx = log.WithModule(ctx, "diff")

View File

@ -1,10 +1,10 @@
package snapshot package snapshots
import ( import (
gocontext "context" gocontext "context"
eventstypes "github.com/containerd/containerd/api/events" eventstypes "github.com/containerd/containerd/api/events"
snapshotapi "github.com/containerd/containerd/api/services/snapshot/v1" snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
"github.com/containerd/containerd/api/types" "github.com/containerd/containerd/api/types"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/events" "github.com/containerd/containerd/events"
@ -12,7 +12,7 @@ import (
"github.com/containerd/containerd/metadata" "github.com/containerd/containerd/metadata"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
ptypes "github.com/gogo/protobuf/types" ptypes "github.com/gogo/protobuf/types"
"golang.org/x/net/context" "golang.org/x/net/context"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -48,7 +48,7 @@ func newService(ic *plugin.InitContext) (interface{}, error) {
}, nil }, nil
} }
func (s *service) getSnapshotter(name string) (snapshot.Snapshotter, error) { func (s *service) getSnapshotter(name string) (snapshots.Snapshotter, error) {
if name == "" { if name == "" {
return nil, errdefs.ToGRPCf(errdefs.ErrInvalidArgument, "snapshotter argument missing") return nil, errdefs.ToGRPCf(errdefs.ErrInvalidArgument, "snapshotter argument missing")
} }
@ -61,20 +61,20 @@ func (s *service) getSnapshotter(name string) (snapshot.Snapshotter, error) {
} }
func (s *service) Register(gs *grpc.Server) error { func (s *service) Register(gs *grpc.Server) error {
snapshotapi.RegisterSnapshotsServer(gs, s) snapshotsapi.RegisterSnapshotsServer(gs, s)
return nil return nil
} }
func (s *service) Prepare(ctx context.Context, pr *snapshotapi.PrepareSnapshotRequest) (*snapshotapi.PrepareSnapshotResponse, error) { func (s *service) Prepare(ctx context.Context, pr *snapshotsapi.PrepareSnapshotRequest) (*snapshotsapi.PrepareSnapshotResponse, error) {
log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing snapshot") log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing snapshot")
sn, err := s.getSnapshotter(pr.Snapshotter) sn, err := s.getSnapshotter(pr.Snapshotter)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var opts []snapshot.Opt var opts []snapshots.Opt
if pr.Labels != nil { if pr.Labels != nil {
opts = append(opts, snapshot.WithLabels(pr.Labels)) opts = append(opts, snapshots.WithLabels(pr.Labels))
} }
mounts, err := sn.Prepare(ctx, pr.Key, pr.Parent, opts...) mounts, err := sn.Prepare(ctx, pr.Key, pr.Parent, opts...)
if err != nil { if err != nil {
@ -87,31 +87,31 @@ func (s *service) Prepare(ctx context.Context, pr *snapshotapi.PrepareSnapshotRe
}); err != nil { }); err != nil {
return nil, err return nil, err
} }
return &snapshotapi.PrepareSnapshotResponse{ return &snapshotsapi.PrepareSnapshotResponse{
Mounts: fromMounts(mounts), Mounts: fromMounts(mounts),
}, nil }, nil
} }
func (s *service) View(ctx context.Context, pr *snapshotapi.ViewSnapshotRequest) (*snapshotapi.ViewSnapshotResponse, error) { func (s *service) View(ctx context.Context, pr *snapshotsapi.ViewSnapshotRequest) (*snapshotsapi.ViewSnapshotResponse, error) {
log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing view snapshot") log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing view snapshot")
sn, err := s.getSnapshotter(pr.Snapshotter) sn, err := s.getSnapshotter(pr.Snapshotter)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var opts []snapshot.Opt var opts []snapshots.Opt
if pr.Labels != nil { if pr.Labels != nil {
opts = append(opts, snapshot.WithLabels(pr.Labels)) opts = append(opts, snapshots.WithLabels(pr.Labels))
} }
mounts, err := sn.View(ctx, pr.Key, pr.Parent, opts...) mounts, err := sn.View(ctx, pr.Key, pr.Parent, opts...)
if err != nil { if err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
return &snapshotapi.ViewSnapshotResponse{ return &snapshotsapi.ViewSnapshotResponse{
Mounts: fromMounts(mounts), Mounts: fromMounts(mounts),
}, nil }, nil
} }
func (s *service) Mounts(ctx context.Context, mr *snapshotapi.MountsRequest) (*snapshotapi.MountsResponse, error) { func (s *service) Mounts(ctx context.Context, mr *snapshotsapi.MountsRequest) (*snapshotsapi.MountsResponse, error) {
log.G(ctx).WithField("key", mr.Key).Debugf("Getting snapshot mounts") log.G(ctx).WithField("key", mr.Key).Debugf("Getting snapshot mounts")
sn, err := s.getSnapshotter(mr.Snapshotter) sn, err := s.getSnapshotter(mr.Snapshotter)
if err != nil { if err != nil {
@ -122,21 +122,21 @@ func (s *service) Mounts(ctx context.Context, mr *snapshotapi.MountsRequest) (*s
if err != nil { if err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
return &snapshotapi.MountsResponse{ return &snapshotsapi.MountsResponse{
Mounts: fromMounts(mounts), Mounts: fromMounts(mounts),
}, nil }, nil
} }
func (s *service) Commit(ctx context.Context, cr *snapshotapi.CommitSnapshotRequest) (*ptypes.Empty, error) { func (s *service) Commit(ctx context.Context, cr *snapshotsapi.CommitSnapshotRequest) (*ptypes.Empty, error) {
log.G(ctx).WithField("key", cr.Key).WithField("name", cr.Name).Debugf("Committing snapshot") log.G(ctx).WithField("key", cr.Key).WithField("name", cr.Name).Debugf("Committing snapshot")
sn, err := s.getSnapshotter(cr.Snapshotter) sn, err := s.getSnapshotter(cr.Snapshotter)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var opts []snapshot.Opt var opts []snapshots.Opt
if cr.Labels != nil { if cr.Labels != nil {
opts = append(opts, snapshot.WithLabels(cr.Labels)) opts = append(opts, snapshots.WithLabels(cr.Labels))
} }
if err := sn.Commit(ctx, cr.Name, cr.Key, opts...); err != nil { if err := sn.Commit(ctx, cr.Name, cr.Key, opts...); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
@ -151,7 +151,7 @@ func (s *service) Commit(ctx context.Context, cr *snapshotapi.CommitSnapshotRequ
return empty, nil return empty, nil
} }
func (s *service) Remove(ctx context.Context, rr *snapshotapi.RemoveSnapshotRequest) (*ptypes.Empty, error) { func (s *service) Remove(ctx context.Context, rr *snapshotsapi.RemoveSnapshotRequest) (*ptypes.Empty, error) {
log.G(ctx).WithField("key", rr.Key).Debugf("Removing snapshot") log.G(ctx).WithField("key", rr.Key).Debugf("Removing snapshot")
sn, err := s.getSnapshotter(rr.Snapshotter) sn, err := s.getSnapshotter(rr.Snapshotter)
if err != nil { if err != nil {
@ -170,7 +170,7 @@ func (s *service) Remove(ctx context.Context, rr *snapshotapi.RemoveSnapshotRequ
return empty, nil return empty, nil
} }
func (s *service) Stat(ctx context.Context, sr *snapshotapi.StatSnapshotRequest) (*snapshotapi.StatSnapshotResponse, error) { func (s *service) Stat(ctx context.Context, sr *snapshotsapi.StatSnapshotRequest) (*snapshotsapi.StatSnapshotResponse, error) {
log.G(ctx).WithField("key", sr.Key).Debugf("Statting snapshot") log.G(ctx).WithField("key", sr.Key).Debugf("Statting snapshot")
sn, err := s.getSnapshotter(sr.Snapshotter) sn, err := s.getSnapshotter(sr.Snapshotter)
if err != nil { if err != nil {
@ -182,10 +182,10 @@ func (s *service) Stat(ctx context.Context, sr *snapshotapi.StatSnapshotRequest)
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
return &snapshotapi.StatSnapshotResponse{Info: fromInfo(info)}, nil return &snapshotsapi.StatSnapshotResponse{Info: fromInfo(info)}, nil
} }
func (s *service) Update(ctx context.Context, sr *snapshotapi.UpdateSnapshotRequest) (*snapshotapi.UpdateSnapshotResponse, error) { func (s *service) Update(ctx context.Context, sr *snapshotsapi.UpdateSnapshotRequest) (*snapshotsapi.UpdateSnapshotResponse, error) {
log.G(ctx).WithField("key", sr.Info.Name).Debugf("Updating snapshot") log.G(ctx).WithField("key", sr.Info.Name).Debugf("Updating snapshot")
sn, err := s.getSnapshotter(sr.Snapshotter) sn, err := s.getSnapshotter(sr.Snapshotter)
if err != nil { if err != nil {
@ -197,24 +197,24 @@ func (s *service) Update(ctx context.Context, sr *snapshotapi.UpdateSnapshotRequ
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
return &snapshotapi.UpdateSnapshotResponse{Info: fromInfo(info)}, nil return &snapshotsapi.UpdateSnapshotResponse{Info: fromInfo(info)}, nil
} }
func (s *service) List(sr *snapshotapi.ListSnapshotsRequest, ss snapshotapi.Snapshots_ListServer) error { func (s *service) List(sr *snapshotsapi.ListSnapshotsRequest, ss snapshotsapi.Snapshots_ListServer) error {
sn, err := s.getSnapshotter(sr.Snapshotter) sn, err := s.getSnapshotter(sr.Snapshotter)
if err != nil { if err != nil {
return err return err
} }
var ( var (
buffer []snapshotapi.Info buffer []snapshotsapi.Info
sendBlock = func(block []snapshotapi.Info) error { sendBlock = func(block []snapshotsapi.Info) error {
return ss.Send(&snapshotapi.ListSnapshotsResponse{ return ss.Send(&snapshotsapi.ListSnapshotsResponse{
Info: block, Info: block,
}) })
} }
) )
err = sn.Walk(ss.Context(), func(ctx gocontext.Context, info snapshot.Info) error { err = sn.Walk(ss.Context(), func(ctx gocontext.Context, info snapshots.Info) error {
buffer = append(buffer, fromInfo(info)) buffer = append(buffer, fromInfo(info))
if len(buffer) >= 100 { if len(buffer) >= 100 {
@ -240,7 +240,7 @@ func (s *service) List(sr *snapshotapi.ListSnapshotsRequest, ss snapshotapi.Snap
return nil return nil
} }
func (s *service) Usage(ctx context.Context, ur *snapshotapi.UsageRequest) (*snapshotapi.UsageResponse, error) { func (s *service) Usage(ctx context.Context, ur *snapshotsapi.UsageRequest) (*snapshotsapi.UsageResponse, error) {
sn, err := s.getSnapshotter(ur.Snapshotter) sn, err := s.getSnapshotter(ur.Snapshotter)
if err != nil { if err != nil {
return nil, err return nil, err
@ -254,18 +254,18 @@ func (s *service) Usage(ctx context.Context, ur *snapshotapi.UsageRequest) (*sna
return fromUsage(usage), nil return fromUsage(usage), nil
} }
func fromKind(kind snapshot.Kind) snapshotapi.Kind { func fromKind(kind snapshots.Kind) snapshotsapi.Kind {
if kind == snapshot.KindActive { if kind == snapshots.KindActive {
return snapshotapi.KindActive return snapshotsapi.KindActive
} }
if kind == snapshot.KindView { if kind == snapshots.KindView {
return snapshotapi.KindView return snapshotsapi.KindView
} }
return snapshotapi.KindCommitted return snapshotsapi.KindCommitted
} }
func fromInfo(info snapshot.Info) snapshotapi.Info { func fromInfo(info snapshots.Info) snapshotsapi.Info {
return snapshotapi.Info{ return snapshotsapi.Info{
Name: info.Name, Name: info.Name,
Parent: info.Parent, Parent: info.Parent,
Kind: fromKind(info.Kind), Kind: fromKind(info.Kind),
@ -275,8 +275,8 @@ func fromInfo(info snapshot.Info) snapshotapi.Info {
} }
} }
func fromUsage(usage snapshot.Usage) *snapshotapi.UsageResponse { func fromUsage(usage snapshots.Usage) *snapshotsapi.UsageResponse {
return &snapshotapi.UsageResponse{ return &snapshotsapi.UsageResponse{
Inodes: usage.Inodes, Inodes: usage.Inodes,
Size_: usage.Size, Size_: usage.Size,
} }
@ -294,8 +294,8 @@ func fromMounts(mounts []mount.Mount) []*types.Mount {
return out return out
} }
func toInfo(info snapshotapi.Info) snapshot.Info { func toInfo(info snapshotsapi.Info) snapshots.Info {
return snapshot.Info{ return snapshots.Info{
Name: info.Name, Name: info.Name,
Parent: info.Parent, Parent: info.Parent,
Kind: toKind(info.Kind), Kind: toKind(info.Kind),
@ -305,12 +305,12 @@ func toInfo(info snapshotapi.Info) snapshot.Info {
} }
} }
func toKind(kind snapshotapi.Kind) snapshot.Kind { func toKind(kind snapshotsapi.Kind) snapshots.Kind {
if kind == snapshotapi.KindActive { if kind == snapshotsapi.KindActive {
return snapshot.KindActive return snapshots.KindActive
} }
if kind == snapshotapi.KindView { if kind == snapshotsapi.KindView {
return snapshot.KindView return snapshots.KindView
} }
return snapshot.KindCommitted return snapshots.KindCommitted
} }

View File

@ -4,17 +4,17 @@ import (
"context" "context"
"io" "io"
snapshotapi "github.com/containerd/containerd/api/services/snapshot/v1" snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
"github.com/containerd/containerd/api/types" "github.com/containerd/containerd/api/types"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
protobuftypes "github.com/gogo/protobuf/types" protobuftypes "github.com/gogo/protobuf/types"
) )
// NewSnapshotterFromClient returns a new Snapshotter which communicates // NewSnapshotterFromClient returns a new Snapshotter which communicates
// over a GRPC connection. // over a GRPC connection.
func NewSnapshotterFromClient(client snapshotapi.SnapshotsClient, snapshotterName string) snapshot.Snapshotter { func NewSnapshotterFromClient(client snapshotsapi.SnapshotsClient, snapshotterName string) snapshots.Snapshotter {
return &remoteSnapshotter{ return &remoteSnapshotter{
client: client, client: client,
snapshotterName: snapshotterName, snapshotterName: snapshotterName,
@ -22,25 +22,25 @@ func NewSnapshotterFromClient(client snapshotapi.SnapshotsClient, snapshotterNam
} }
type remoteSnapshotter struct { type remoteSnapshotter struct {
client snapshotapi.SnapshotsClient client snapshotsapi.SnapshotsClient
snapshotterName string snapshotterName string
} }
func (r *remoteSnapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { func (r *remoteSnapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) {
resp, err := r.client.Stat(ctx, resp, err := r.client.Stat(ctx,
&snapshotapi.StatSnapshotRequest{ &snapshotsapi.StatSnapshotRequest{
Snapshotter: r.snapshotterName, Snapshotter: r.snapshotterName,
Key: key, Key: key,
}) })
if err != nil { if err != nil {
return snapshot.Info{}, errdefs.FromGRPC(err) return snapshots.Info{}, errdefs.FromGRPC(err)
} }
return toInfo(resp.Info), nil return toInfo(resp.Info), nil
} }
func (r *remoteSnapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { func (r *remoteSnapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
resp, err := r.client.Update(ctx, resp, err := r.client.Update(ctx,
&snapshotapi.UpdateSnapshotRequest{ &snapshotsapi.UpdateSnapshotRequest{
Snapshotter: r.snapshotterName, Snapshotter: r.snapshotterName,
Info: fromInfo(info), Info: fromInfo(info),
UpdateMask: &protobuftypes.FieldMask{ UpdateMask: &protobuftypes.FieldMask{
@ -48,24 +48,24 @@ func (r *remoteSnapshotter) Update(ctx context.Context, info snapshot.Info, fiel
}, },
}) })
if err != nil { if err != nil {
return snapshot.Info{}, errdefs.FromGRPC(err) return snapshots.Info{}, errdefs.FromGRPC(err)
} }
return toInfo(resp.Info), nil return toInfo(resp.Info), nil
} }
func (r *remoteSnapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { func (r *remoteSnapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) {
resp, err := r.client.Usage(ctx, &snapshotapi.UsageRequest{ resp, err := r.client.Usage(ctx, &snapshotsapi.UsageRequest{
Snapshotter: r.snapshotterName, Snapshotter: r.snapshotterName,
Key: key, Key: key,
}) })
if err != nil { if err != nil {
return snapshot.Usage{}, errdefs.FromGRPC(err) return snapshots.Usage{}, errdefs.FromGRPC(err)
} }
return toUsage(resp), nil return toUsage(resp), nil
} }
func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) { func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) {
resp, err := r.client.Mounts(ctx, &snapshotapi.MountsRequest{ resp, err := r.client.Mounts(ctx, &snapshotsapi.MountsRequest{
Snapshotter: r.snapshotterName, Snapshotter: r.snapshotterName,
Key: key, Key: key,
}) })
@ -75,14 +75,14 @@ func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mou
return toMounts(resp.Mounts), nil return toMounts(resp.Mounts), nil
} }
func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
var local snapshot.Info var local snapshots.Info
for _, opt := range opts { for _, opt := range opts {
if err := opt(&local); err != nil { if err := opt(&local); err != nil {
return nil, err return nil, err
} }
} }
resp, err := r.client.Prepare(ctx, &snapshotapi.PrepareSnapshotRequest{ resp, err := r.client.Prepare(ctx, &snapshotsapi.PrepareSnapshotRequest{
Snapshotter: r.snapshotterName, Snapshotter: r.snapshotterName,
Key: key, Key: key,
Parent: parent, Parent: parent,
@ -94,14 +94,14 @@ func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string, opt
return toMounts(resp.Mounts), nil return toMounts(resp.Mounts), nil
} }
func (r *remoteSnapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (r *remoteSnapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
var local snapshot.Info var local snapshots.Info
for _, opt := range opts { for _, opt := range opts {
if err := opt(&local); err != nil { if err := opt(&local); err != nil {
return nil, err return nil, err
} }
} }
resp, err := r.client.View(ctx, &snapshotapi.ViewSnapshotRequest{ resp, err := r.client.View(ctx, &snapshotsapi.ViewSnapshotRequest{
Snapshotter: r.snapshotterName, Snapshotter: r.snapshotterName,
Key: key, Key: key,
Parent: parent, Parent: parent,
@ -113,14 +113,14 @@ func (r *remoteSnapshotter) View(ctx context.Context, key, parent string, opts .
return toMounts(resp.Mounts), nil return toMounts(resp.Mounts), nil
} }
func (r *remoteSnapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { func (r *remoteSnapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
var local snapshot.Info var local snapshots.Info
for _, opt := range opts { for _, opt := range opts {
if err := opt(&local); err != nil { if err := opt(&local); err != nil {
return err return err
} }
} }
_, err := r.client.Commit(ctx, &snapshotapi.CommitSnapshotRequest{ _, err := r.client.Commit(ctx, &snapshotsapi.CommitSnapshotRequest{
Snapshotter: r.snapshotterName, Snapshotter: r.snapshotterName,
Name: name, Name: name,
Key: key, Key: key,
@ -130,15 +130,15 @@ func (r *remoteSnapshotter) Commit(ctx context.Context, name, key string, opts .
} }
func (r *remoteSnapshotter) Remove(ctx context.Context, key string) error { func (r *remoteSnapshotter) Remove(ctx context.Context, key string) error {
_, err := r.client.Remove(ctx, &snapshotapi.RemoveSnapshotRequest{ _, err := r.client.Remove(ctx, &snapshotsapi.RemoveSnapshotRequest{
Snapshotter: r.snapshotterName, Snapshotter: r.snapshotterName,
Key: key, Key: key,
}) })
return errdefs.FromGRPC(err) return errdefs.FromGRPC(err)
} }
func (r *remoteSnapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { func (r *remoteSnapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
sc, err := r.client.List(ctx, &snapshotapi.ListSnapshotsRequest{ sc, err := r.client.List(ctx, &snapshotsapi.ListSnapshotsRequest{
Snapshotter: r.snapshotterName, Snapshotter: r.snapshotterName,
}) })
if err != nil { if err != nil {
@ -167,18 +167,18 @@ func (r *remoteSnapshotter) Close() error {
return nil return nil
} }
func toKind(kind snapshotapi.Kind) snapshot.Kind { func toKind(kind snapshotsapi.Kind) snapshots.Kind {
if kind == snapshotapi.KindActive { if kind == snapshotsapi.KindActive {
return snapshot.KindActive return snapshots.KindActive
} }
if kind == snapshotapi.KindView { if kind == snapshotsapi.KindView {
return snapshot.KindView return snapshots.KindView
} }
return snapshot.KindCommitted return snapshots.KindCommitted
} }
func toInfo(info snapshotapi.Info) snapshot.Info { func toInfo(info snapshotsapi.Info) snapshots.Info {
return snapshot.Info{ return snapshots.Info{
Name: info.Name, Name: info.Name,
Parent: info.Parent, Parent: info.Parent,
Kind: toKind(info.Kind), Kind: toKind(info.Kind),
@ -188,8 +188,8 @@ func toInfo(info snapshotapi.Info) snapshot.Info {
} }
} }
func toUsage(resp *snapshotapi.UsageResponse) snapshot.Usage { func toUsage(resp *snapshotsapi.UsageResponse) snapshots.Usage {
return snapshot.Usage{ return snapshots.Usage{
Inodes: resp.Inodes, Inodes: resp.Inodes,
Size: resp.Size_, Size: resp.Size_,
} }
@ -207,18 +207,18 @@ func toMounts(mm []*types.Mount) []mount.Mount {
return mounts return mounts
} }
func fromKind(kind snapshot.Kind) snapshotapi.Kind { func fromKind(kind snapshots.Kind) snapshotsapi.Kind {
if kind == snapshot.KindActive { if kind == snapshots.KindActive {
return snapshotapi.KindActive return snapshotsapi.KindActive
} }
if kind == snapshot.KindView { if kind == snapshots.KindView {
return snapshotapi.KindView return snapshotsapi.KindView
} }
return snapshotapi.KindCommitted return snapshotsapi.KindCommitted
} }
func fromInfo(info snapshot.Info) snapshotapi.Info { func fromInfo(info snapshots.Info) snapshotsapi.Info {
return snapshotapi.Info{ return snapshotsapi.Info{
Name: info.Name, Name: info.Name,
Parent: info.Parent, Parent: info.Parent,
Kind: fromKind(info.Kind), Kind: fromKind(info.Kind),

View File

@ -5,11 +5,11 @@ import (
"runtime" "runtime"
"testing" "testing"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshot/testsuite" "github.com/containerd/containerd/snapshots/testsuite"
) )
func newSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error) { func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) {
client, err := New(address) client, err := New(address)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err

View File

@ -14,8 +14,8 @@ import (
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/platforms" "github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshot/storage" "github.com/containerd/containerd/snapshots/storage"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -43,7 +43,7 @@ type snapshotter struct {
// root directory for snapshots and stores the metadata in // root directory for snapshots and stores the metadata in
// a file in the provided root. // a file in the provided root.
// root needs to be a mount point of btrfs. // root needs to be a mount point of btrfs.
func NewSnapshotter(root string) (snapshot.Snapshotter, error) { func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
// If directory does not exist, create it // If directory does not exist, create it
if _, err := os.Stat(root); err != nil { if _, err := os.Stat(root); err != nil {
if !os.IsNotExist(err) { if !os.IsNotExist(err) {
@ -93,41 +93,41 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
// //
// Should be used for parent resolution, existence checks and to discern // Should be used for parent resolution, existence checks and to discern
// the kind of snapshot. // the kind of snapshot.
func (b *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { func (b *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) {
ctx, t, err := b.ms.TransactionContext(ctx, false) ctx, t, err := b.ms.TransactionContext(ctx, false)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
defer t.Rollback() defer t.Rollback()
_, info, _, err := storage.GetInfo(ctx, key) _, info, _, err := storage.GetInfo(ctx, key)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
return info, nil return info, nil
} }
func (b *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { func (b *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
ctx, t, err := b.ms.TransactionContext(ctx, true) ctx, t, err := b.ms.TransactionContext(ctx, true)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
info, err = storage.UpdateInfo(ctx, info, fieldpaths...) info, err = storage.UpdateInfo(ctx, info, fieldpaths...)
if err != nil { if err != nil {
t.Rollback() t.Rollback()
return snapshot.Info{}, err return snapshots.Info{}, err
} }
if err := t.Commit(); err != nil { if err := t.Commit(); err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
return info, nil return info, nil
} }
// Usage retrieves the disk usage of the top-level snapshot. // Usage retrieves the disk usage of the top-level snapshot.
func (b *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { func (b *snapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) {
panic("not implemented") panic("not implemented")
// TODO(stevvooe): Btrfs has a quota model where data can be exclusive to a // TODO(stevvooe): Btrfs has a quota model where data can be exclusive to a
@ -143,7 +143,7 @@ func (b *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, er
} }
// Walk the committed snapshots. // Walk the committed snapshots.
func (b *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { func (b *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
ctx, t, err := b.ms.TransactionContext(ctx, false) ctx, t, err := b.ms.TransactionContext(ctx, false)
if err != nil { if err != nil {
return err return err
@ -152,15 +152,15 @@ func (b *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho
return storage.WalkInfo(ctx, fn) return storage.WalkInfo(ctx, fn)
} }
func (b *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (b *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
return b.makeSnapshot(ctx, snapshot.KindActive, key, parent, opts) return b.makeSnapshot(ctx, snapshots.KindActive, key, parent, opts)
} }
func (b *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (b *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
return b.makeSnapshot(ctx, snapshot.KindView, key, parent, opts) return b.makeSnapshot(ctx, snapshots.KindView, key, parent, opts)
} }
func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, opts []snapshot.Opt) ([]mount.Mount, error) { func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts []snapshots.Opt) ([]mount.Mount, error) {
ctx, t, err := b.ms.TransactionContext(ctx, true) ctx, t, err := b.ms.TransactionContext(ctx, true)
if err != nil { if err != nil {
return nil, err return nil, err
@ -190,7 +190,7 @@ func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshot.Kind, key,
parentp := filepath.Join(b.root, "snapshots", s.ParentIDs[0]) parentp := filepath.Join(b.root, "snapshots", s.ParentIDs[0])
var readonly bool var readonly bool
if kind == snapshot.KindView { if kind == snapshots.KindView {
readonly = true readonly = true
} }
@ -222,7 +222,7 @@ func (b *snapshotter) mounts(dir string, s storage.Snapshot) ([]mount.Mount, err
options = append(options, fmt.Sprintf("subvolid=%d", sid)) options = append(options, fmt.Sprintf("subvolid=%d", sid))
if s.Kind != snapshot.KindActive { if s.Kind != snapshots.KindActive {
options = append(options, "ro") options = append(options, "ro")
} }
@ -237,7 +237,7 @@ func (b *snapshotter) mounts(dir string, s storage.Snapshot) ([]mount.Mount, err
}, nil }, nil
} }
func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) (err error) { func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) (err error) {
ctx, t, err := b.ms.TransactionContext(ctx, true) ctx, t, err := b.ms.TransactionContext(ctx, true)
if err != nil { if err != nil {
return err return err
@ -250,7 +250,7 @@ func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
} }
}() }()
id, err := storage.CommitActive(ctx, key, name, snapshot.Usage{}, opts...) // TODO(stevvooe): Resolve a usage value for btrfs id, err := storage.CommitActive(ctx, key, name, snapshots.Usage{}, opts...) // TODO(stevvooe): Resolve a usage value for btrfs
if err != nil { if err != nil {
return errors.Wrap(err, "failed to commit") return errors.Wrap(err, "failed to commit")
} }
@ -330,14 +330,14 @@ func (b *snapshotter) Remove(ctx context.Context, key string) (err error) {
} }
switch k { switch k {
case snapshot.KindView: case snapshots.KindView:
source = filepath.Join(b.root, "view", id) source = filepath.Join(b.root, "view", id)
removed = filepath.Join(b.root, "view", "rm-"+id) removed = filepath.Join(b.root, "view", "rm-"+id)
readonly = true readonly = true
case snapshot.KindActive: case snapshots.KindActive:
source = filepath.Join(b.root, "active", id) source = filepath.Join(b.root, "active", id)
removed = filepath.Join(b.root, "active", "rm-"+id) removed = filepath.Join(b.root, "active", "rm-"+id)
case snapshot.KindCommitted: case snapshots.KindCommitted:
source = filepath.Join(b.root, "snapshots", id) source = filepath.Join(b.root, "snapshots", id)
removed = filepath.Join(b.root, "snapshots", "rm-"+id) removed = filepath.Join(b.root, "snapshots", "rm-"+id)
readonly = true readonly = true

View File

@ -12,14 +12,14 @@ import (
"testing" "testing"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshot/testsuite" "github.com/containerd/containerd/snapshots/testsuite"
"github.com/containerd/containerd/testutil" "github.com/containerd/containerd/testutil"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshot.Snapshotter, func() error, error) { func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshots.Snapshotter, func() error, error) {
mkbtrfs, err := exec.LookPath("mkfs.btrfs") mkbtrfs, err := exec.LookPath("mkfs.btrfs")
if err != nil { if err != nil {
t.Skipf("could not find mkfs.btrfs: %v", err) t.Skipf("could not find mkfs.btrfs: %v", err)
@ -27,7 +27,7 @@ func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshot.Snaps
// TODO: Check for btrfs in /proc/module and skip if not loaded // TODO: Check for btrfs in /proc/module and skip if not loaded
return func(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error) { return func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) {
deviceName, cleanupDevice, err := testutil.NewLoopback(100 << 20) // 100 MB deviceName, cleanupDevice, err := testutil.NewLoopback(100 << 20) // 100 MB
if err != nil { if err != nil {

View File

@ -11,8 +11,8 @@ import (
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/platforms" "github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshot/storage" "github.com/containerd/containerd/snapshots/storage"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -34,7 +34,7 @@ type snapshotter struct {
// NewSnapshotter returns a Snapshotter which copies layers on the underlying // NewSnapshotter returns a Snapshotter which copies layers on the underlying
// file system. A metadata file is stored under the root. // file system. A metadata file is stored under the root.
func NewSnapshotter(root string) (snapshot.Snapshotter, error) { func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
if err := os.MkdirAll(root, 0700); err != nil { if err := os.MkdirAll(root, 0700); err != nil {
return nil, err return nil, err
} }
@ -58,68 +58,68 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
// //
// Should be used for parent resolution, existence checks and to discern // Should be used for parent resolution, existence checks and to discern
// the kind of snapshot. // the kind of snapshot.
func (o *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { func (o *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) {
ctx, t, err := o.ms.TransactionContext(ctx, false) ctx, t, err := o.ms.TransactionContext(ctx, false)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
defer t.Rollback() defer t.Rollback()
_, info, _, err := storage.GetInfo(ctx, key) _, info, _, err := storage.GetInfo(ctx, key)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
return info, nil return info, nil
} }
func (o *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { func (o *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
ctx, t, err := o.ms.TransactionContext(ctx, true) ctx, t, err := o.ms.TransactionContext(ctx, true)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
info, err = storage.UpdateInfo(ctx, info, fieldpaths...) info, err = storage.UpdateInfo(ctx, info, fieldpaths...)
if err != nil { if err != nil {
t.Rollback() t.Rollback()
return snapshot.Info{}, err return snapshots.Info{}, err
} }
if err := t.Commit(); err != nil { if err := t.Commit(); err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
return info, nil return info, nil
} }
func (o *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { func (o *snapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) {
ctx, t, err := o.ms.TransactionContext(ctx, false) ctx, t, err := o.ms.TransactionContext(ctx, false)
if err != nil { if err != nil {
return snapshot.Usage{}, err return snapshots.Usage{}, err
} }
defer t.Rollback() defer t.Rollback()
id, info, usage, err := storage.GetInfo(ctx, key) id, info, usage, err := storage.GetInfo(ctx, key)
if err != nil { if err != nil {
return snapshot.Usage{}, err return snapshots.Usage{}, err
} }
if info.Kind == snapshot.KindActive { if info.Kind == snapshots.KindActive {
du, err := fs.DiskUsage(o.getSnapshotDir(id)) du, err := fs.DiskUsage(o.getSnapshotDir(id))
if err != nil { if err != nil {
return snapshot.Usage{}, err return snapshots.Usage{}, err
} }
usage = snapshot.Usage(du) usage = snapshots.Usage(du)
} }
return usage, nil return usage, nil
} }
func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
return o.createSnapshot(ctx, snapshot.KindActive, key, parent, opts) return o.createSnapshot(ctx, snapshots.KindActive, key, parent, opts)
} }
func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
return o.createSnapshot(ctx, snapshot.KindView, key, parent, opts) return o.createSnapshot(ctx, snapshots.KindView, key, parent, opts)
} }
// Mounts returns the mounts for the transaction identified by key. Can be // Mounts returns the mounts for the transaction identified by key. Can be
@ -139,7 +139,7 @@ func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er
return o.mounts(s), nil return o.mounts(s), nil
} }
func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
ctx, t, err := o.ms.TransactionContext(ctx, true) ctx, t, err := o.ms.TransactionContext(ctx, true)
if err != nil { if err != nil {
return err return err
@ -155,7 +155,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
return err return err
} }
if _, err := storage.CommitActive(ctx, key, name, snapshot.Usage(usage), opts...); err != nil { if _, err := storage.CommitActive(ctx, key, name, snapshots.Usage(usage), opts...); err != nil {
if rerr := t.Rollback(); rerr != nil { if rerr := t.Rollback(); rerr != nil {
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
} }
@ -215,7 +215,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) {
} }
// Walk the committed snapshots. // Walk the committed snapshots.
func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
ctx, t, err := o.ms.TransactionContext(ctx, false) ctx, t, err := o.ms.TransactionContext(ctx, false)
if err != nil { if err != nil {
return err return err
@ -224,13 +224,13 @@ func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho
return storage.WalkInfo(ctx, fn) return storage.WalkInfo(ctx, fn)
} }
func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, opts []snapshot.Opt) ([]mount.Mount, error) { func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts []snapshots.Opt) ([]mount.Mount, error) {
var ( var (
err error err error
path, td string path, td string
) )
if kind == snapshot.KindActive || parent == "" { if kind == snapshots.KindActive || parent == "" {
td, err = ioutil.TempDir(filepath.Join(o.root, "snapshots"), "new-") td, err = ioutil.TempDir(filepath.Join(o.root, "snapshots"), "new-")
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to create temp dir") return nil, errors.Wrap(err, "failed to create temp dir")
@ -299,13 +299,13 @@ func (o *snapshotter) mounts(s storage.Snapshot) []mount.Mount {
source string source string
) )
if s.Kind == snapshot.KindView { if s.Kind == snapshots.KindView {
roFlag = "ro" roFlag = "ro"
} else { } else {
roFlag = "rw" roFlag = "rw"
} }
if len(s.ParentIDs) == 0 || s.Kind == snapshot.KindActive { if len(s.ParentIDs) == 0 || s.Kind == snapshots.KindActive {
source = o.getSnapshotDir(s.ID) source = o.getSnapshotDir(s.ID)
} else { } else {
source = o.getSnapshotDir(s.ParentIDs[0]) source = o.getSnapshotDir(s.ParentIDs[0])

View File

@ -5,12 +5,12 @@ import (
"runtime" "runtime"
"testing" "testing"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshot/testsuite" "github.com/containerd/containerd/snapshots/testsuite"
"github.com/containerd/containerd/testutil" "github.com/containerd/containerd/testutil"
) )
func newSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error) { func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) {
snapshotter, err := NewSnapshotter(root) snapshotter, err := NewSnapshotter(root)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err

View File

@ -16,8 +16,8 @@ import (
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/platforms" "github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshot/storage" "github.com/containerd/containerd/snapshots/storage"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -41,7 +41,7 @@ type snapshotter struct {
// NewSnapshotter returns a Snapshotter which uses overlayfs. The overlayfs // NewSnapshotter returns a Snapshotter which uses overlayfs. The overlayfs
// diffs are stored under the provided root. A metadata file is stored under // diffs are stored under the provided root. A metadata file is stored under
// the root. // the root.
func NewSnapshotter(root string) (snapshot.Snapshotter, error) { func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
if err := os.MkdirAll(root, 0700); err != nil { if err := os.MkdirAll(root, 0700); err != nil {
return nil, err return nil, err
} }
@ -72,34 +72,34 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
// //
// Should be used for parent resolution, existence checks and to discern // Should be used for parent resolution, existence checks and to discern
// the kind of snapshot. // the kind of snapshot.
func (o *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { func (o *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) {
ctx, t, err := o.ms.TransactionContext(ctx, false) ctx, t, err := o.ms.TransactionContext(ctx, false)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
defer t.Rollback() defer t.Rollback()
_, info, _, err := storage.GetInfo(ctx, key) _, info, _, err := storage.GetInfo(ctx, key)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
return info, nil return info, nil
} }
func (o *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { func (o *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
ctx, t, err := o.ms.TransactionContext(ctx, true) ctx, t, err := o.ms.TransactionContext(ctx, true)
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
info, err = storage.UpdateInfo(ctx, info, fieldpaths...) info, err = storage.UpdateInfo(ctx, info, fieldpaths...)
if err != nil { if err != nil {
t.Rollback() t.Rollback()
return snapshot.Info{}, err return snapshots.Info{}, err
} }
if err := t.Commit(); err != nil { if err := t.Commit(); err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
return info, nil return info, nil
@ -111,39 +111,39 @@ func (o *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths
// "upper") directory and may take some time. // "upper") directory and may take some time.
// //
// For committed snapshots, the value is returned from the metadata database. // For committed snapshots, the value is returned from the metadata database.
func (o *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { func (o *snapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) {
ctx, t, err := o.ms.TransactionContext(ctx, false) ctx, t, err := o.ms.TransactionContext(ctx, false)
if err != nil { if err != nil {
return snapshot.Usage{}, err return snapshots.Usage{}, err
} }
id, info, usage, err := storage.GetInfo(ctx, key) id, info, usage, err := storage.GetInfo(ctx, key)
t.Rollback() // transaction no longer needed at this point. t.Rollback() // transaction no longer needed at this point.
if err != nil { if err != nil {
return snapshot.Usage{}, err return snapshots.Usage{}, err
} }
upperPath := o.upperPath(id) upperPath := o.upperPath(id)
if info.Kind == snapshot.KindActive { if info.Kind == snapshots.KindActive {
du, err := fs.DiskUsage(upperPath) du, err := fs.DiskUsage(upperPath)
if err != nil { if err != nil {
// TODO(stevvooe): Consider not reporting an error in this case. // TODO(stevvooe): Consider not reporting an error in this case.
return snapshot.Usage{}, err return snapshots.Usage{}, err
} }
usage = snapshot.Usage(du) usage = snapshots.Usage(du)
} }
return usage, nil return usage, nil
} }
func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
return o.createSnapshot(ctx, snapshot.KindActive, key, parent, opts) return o.createSnapshot(ctx, snapshots.KindActive, key, parent, opts)
} }
func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
return o.createSnapshot(ctx, snapshot.KindView, key, parent, opts) return o.createSnapshot(ctx, snapshots.KindView, key, parent, opts)
} }
// Mounts returns the mounts for the transaction identified by key. Can be // Mounts returns the mounts for the transaction identified by key. Can be
@ -163,7 +163,7 @@ func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er
return o.mounts(s), nil return o.mounts(s), nil
} }
func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
ctx, t, err := o.ms.TransactionContext(ctx, true) ctx, t, err := o.ms.TransactionContext(ctx, true)
if err != nil { if err != nil {
return err return err
@ -188,7 +188,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
return err return err
} }
if _, err = storage.CommitActive(ctx, key, name, snapshot.Usage(usage), opts...); err != nil { if _, err = storage.CommitActive(ctx, key, name, snapshots.Usage(usage), opts...); err != nil {
return errors.Wrap(err, "failed to commit snapshot") return errors.Wrap(err, "failed to commit snapshot")
} }
return t.Commit() return t.Commit()
@ -238,7 +238,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) {
} }
// Walk the committed snapshots. // Walk the committed snapshots.
func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
ctx, t, err := o.ms.TransactionContext(ctx, false) ctx, t, err := o.ms.TransactionContext(ctx, false)
if err != nil { if err != nil {
return err return err
@ -247,7 +247,7 @@ func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho
return storage.WalkInfo(ctx, fn) return storage.WalkInfo(ctx, fn)
} }
func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, opts []snapshot.Opt) ([]mount.Mount, error) { func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts []snapshots.Opt) ([]mount.Mount, error) {
var ( var (
path string path string
snapshotDir = filepath.Join(o.root, "snapshots") snapshotDir = filepath.Join(o.root, "snapshots")
@ -277,7 +277,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshot.Kind, ke
return nil, err return nil, err
} }
if kind == snapshot.KindActive { if kind == snapshots.KindActive {
if err = os.MkdirAll(filepath.Join(td, "work"), 0711); err != nil { if err = os.MkdirAll(filepath.Join(td, "work"), 0711); err != nil {
return nil, err return nil, err
} }
@ -336,7 +336,7 @@ func (o *snapshotter) mounts(s storage.Snapshot) []mount.Mount {
// if we only have one layer/no parents then just return a bind mount as overlay // if we only have one layer/no parents then just return a bind mount as overlay
// will not work // will not work
roFlag := "rw" roFlag := "rw"
if s.Kind == snapshot.KindView { if s.Kind == snapshots.KindView {
roFlag = "ro" roFlag = "ro"
} }
@ -353,7 +353,7 @@ func (o *snapshotter) mounts(s storage.Snapshot) []mount.Mount {
} }
var options []string var options []string
if s.Kind == snapshot.KindActive { if s.Kind == snapshots.KindActive {
options = append(options, options = append(options,
fmt.Sprintf("workdir=%s", o.workPath(s.ID)), fmt.Sprintf("workdir=%s", o.workPath(s.ID)),
fmt.Sprintf("upperdir=%s", o.upperPath(s.ID)), fmt.Sprintf("upperdir=%s", o.upperPath(s.ID)),

View File

@ -12,13 +12,13 @@ import (
"testing" "testing"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshot/storage" "github.com/containerd/containerd/snapshots/storage"
"github.com/containerd/containerd/snapshot/testsuite" "github.com/containerd/containerd/snapshots/testsuite"
"github.com/containerd/containerd/testutil" "github.com/containerd/containerd/testutil"
) )
func newSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error) { func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) {
snapshotter, err := NewSnapshotter(root) snapshotter, err := NewSnapshotter(root)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -150,7 +150,7 @@ func TestOverlayOverlayMount(t *testing.T) {
} }
} }
func getBasePath(ctx context.Context, sn snapshot.Snapshotter, root, key string) string { func getBasePath(ctx context.Context, sn snapshots.Snapshotter, root, key string) string {
o := sn.(*snapshotter) o := sn.(*snapshotter)
ctx, t, err := o.ms.TransactionContext(ctx, false) ctx, t, err := o.ms.TransactionContext(ctx, false)
if err != nil { if err != nil {
@ -166,7 +166,7 @@ func getBasePath(ctx context.Context, sn snapshot.Snapshotter, root, key string)
return filepath.Join(root, "snapshots", s.ID) return filepath.Join(root, "snapshots", s.ID)
} }
func getParents(ctx context.Context, sn snapshot.Snapshotter, root, key string) []string { func getParents(ctx context.Context, sn snapshots.Snapshotter, root, key string) []string {
o := sn.(*snapshotter) o := sn.(*snapshotter)
ctx, t, err := o.ms.TransactionContext(ctx, false) ctx, t, err := o.ms.TransactionContext(ctx, false)
if err != nil { if err != nil {

View File

@ -1,4 +1,4 @@
package snapshot package snapshots
import ( import (
"context" "context"

View File

@ -10,7 +10,7 @@ import (
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/metadata/boltutil" "github.com/containerd/containerd/metadata/boltutil"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -56,11 +56,11 @@ func getParentPrefix(b []byte) uint64 {
// GetInfo returns the snapshot Info directly from the metadata. Requires a // GetInfo returns the snapshot Info directly from the metadata. Requires a
// context with a storage transaction. // context with a storage transaction.
func GetInfo(ctx context.Context, key string) (string, snapshot.Info, snapshot.Usage, error) { func GetInfo(ctx context.Context, key string) (string, snapshots.Info, snapshots.Usage, error) {
var ( var (
id uint64 id uint64
su snapshot.Usage su snapshots.Usage
si = snapshot.Info{ si = snapshots.Info{
Name: key, Name: key,
} }
) )
@ -69,15 +69,15 @@ func GetInfo(ctx context.Context, key string) (string, snapshot.Info, snapshot.U
return readSnapshot(bkt, &id, &si) return readSnapshot(bkt, &id, &si)
}) })
if err != nil { if err != nil {
return "", snapshot.Info{}, snapshot.Usage{}, err return "", snapshots.Info{}, snapshots.Usage{}, err
} }
return fmt.Sprintf("%d", id), si, su, nil return fmt.Sprintf("%d", id), si, su, nil
} }
// UpdateInfo updates an existing snapshot info's data // UpdateInfo updates an existing snapshot info's data
func UpdateInfo(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { func UpdateInfo(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
updated := snapshot.Info{ updated := snapshots.Info{
Name: info.Name, Name: info.Name,
} }
err := withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error { err := withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
@ -120,7 +120,7 @@ func UpdateInfo(ctx context.Context, info snapshot.Info, fieldpaths ...string) (
return boltutil.WriteLabels(sbkt, updated.Labels) return boltutil.WriteLabels(sbkt, updated.Labels)
}) })
if err != nil { if err != nil {
return snapshot.Info{}, err return snapshots.Info{}, err
} }
return updated, nil return updated, nil
} }
@ -128,7 +128,7 @@ func UpdateInfo(ctx context.Context, info snapshot.Info, fieldpaths ...string) (
// WalkInfo iterates through all metadata Info for the stored snapshots and // WalkInfo iterates through all metadata Info for the stored snapshots and
// calls the provided function for each. Requires a context with a storage // calls the provided function for each. Requires a context with a storage
// transaction. // transaction.
func WalkInfo(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { func WalkInfo(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
return withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error { return withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
return bkt.ForEach(func(k, v []byte) error { return bkt.ForEach(func(k, v []byte) error {
// skip non buckets // skip non buckets
@ -137,7 +137,7 @@ func WalkInfo(ctx context.Context, fn func(context.Context, snapshot.Info) error
} }
var ( var (
sbkt = bkt.Bucket(k) sbkt = bkt.Bucket(k)
si = snapshot.Info{ si = snapshots.Info{
Name: string(k), Name: string(k),
} }
) )
@ -162,7 +162,7 @@ func GetSnapshot(ctx context.Context, key string) (s Snapshot, err error) {
s.ID = fmt.Sprintf("%d", readID(sbkt)) s.ID = fmt.Sprintf("%d", readID(sbkt))
s.Kind = readKind(sbkt) s.Kind = readKind(sbkt)
if s.Kind != snapshot.KindActive && s.Kind != snapshot.KindView { if s.Kind != snapshots.KindActive && s.Kind != snapshots.KindView {
return errors.Wrapf(errdefs.ErrFailedPrecondition, "requested snapshot %v not active or view", key) return errors.Wrapf(errdefs.ErrFailedPrecondition, "requested snapshot %v not active or view", key)
} }
@ -187,13 +187,13 @@ func GetSnapshot(ctx context.Context, key string) (s Snapshot, err error) {
} }
// CreateSnapshot inserts a record for an active or view snapshot with the provided parent. // CreateSnapshot inserts a record for an active or view snapshot with the provided parent.
func CreateSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, opts ...snapshot.Opt) (s Snapshot, err error) { func CreateSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts ...snapshots.Opt) (s Snapshot, err error) {
switch kind { switch kind {
case snapshot.KindActive, snapshot.KindView: case snapshots.KindActive, snapshots.KindView:
default: default:
return Snapshot{}, errors.Wrapf(errdefs.ErrInvalidArgument, "snapshot type %v invalid; only snapshots of type Active or View can be created", kind) return Snapshot{}, errors.Wrapf(errdefs.ErrInvalidArgument, "snapshot type %v invalid; only snapshots of type Active or View can be created", kind)
} }
var base snapshot.Info var base snapshots.Info
for _, opt := range opts { for _, opt := range opts {
if err := opt(&base); err != nil { if err := opt(&base); err != nil {
return Snapshot{}, err return Snapshot{}, err
@ -210,7 +210,7 @@ func CreateSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string,
return errors.Wrap(errdefs.ErrNotFound, "missing parent bucket") return errors.Wrap(errdefs.ErrNotFound, "missing parent bucket")
} }
if readKind(spbkt) != snapshot.KindCommitted { if readKind(spbkt) != snapshots.KindCommitted {
return errors.Wrap(errdefs.ErrInvalidArgument, "parent is not committed snapshot") return errors.Wrap(errdefs.ErrInvalidArgument, "parent is not committed snapshot")
} }
} }
@ -228,7 +228,7 @@ func CreateSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string,
} }
t := time.Now().UTC() t := time.Now().UTC()
si := snapshot.Info{ si := snapshots.Info{
Parent: parent, Parent: parent,
Kind: kind, Kind: kind,
Labels: base.Labels, Labels: base.Labels,
@ -268,10 +268,10 @@ func CreateSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string,
// Remove removes a snapshot from the metastore. The string identifier for the // Remove removes a snapshot from the metastore. The string identifier for the
// snapshot is returned as well as the kind. The provided context must contain a // snapshot is returned as well as the kind. The provided context must contain a
// writable transaction. // writable transaction.
func Remove(ctx context.Context, key string) (string, snapshot.Kind, error) { func Remove(ctx context.Context, key string) (string, snapshots.Kind, error) {
var ( var (
id uint64 id uint64
si snapshot.Info si snapshots.Info
) )
if err := withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error { if err := withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
@ -320,10 +320,10 @@ func Remove(ctx context.Context, key string) (string, snapshot.Kind, error) {
// lookup or removal. The returned string identifier for the committed snapshot // lookup or removal. The returned string identifier for the committed snapshot
// is the same identifier of the original active snapshot. The provided context // is the same identifier of the original active snapshot. The provided context
// must contain a writable transaction. // must contain a writable transaction.
func CommitActive(ctx context.Context, key, name string, usage snapshot.Usage, opts ...snapshot.Opt) (string, error) { func CommitActive(ctx context.Context, key, name string, usage snapshots.Usage, opts ...snapshots.Opt) (string, error) {
var ( var (
id uint64 id uint64
base snapshot.Info base snapshots.Info
) )
for _, opt := range opts { for _, opt := range opts {
if err := opt(&base); err != nil { if err := opt(&base); err != nil {
@ -344,15 +344,15 @@ func CommitActive(ctx context.Context, key, name string, usage snapshot.Usage, o
return errors.Wrap(errdefs.ErrNotFound, "failed to get active snapshot") return errors.Wrap(errdefs.ErrNotFound, "failed to get active snapshot")
} }
var si snapshot.Info var si snapshots.Info
if err := readSnapshot(sbkt, &id, &si); err != nil { if err := readSnapshot(sbkt, &id, &si); err != nil {
return errors.Wrap(err, "failed to read snapshot") return errors.Wrap(err, "failed to read snapshot")
} }
if si.Kind != snapshot.KindActive { if si.Kind != snapshots.KindActive {
return errors.Wrapf(errdefs.ErrFailedPrecondition, "snapshot %v is not active", name) return errors.Wrapf(errdefs.ErrFailedPrecondition, "snapshot %v is not active", name)
} }
si.Kind = snapshot.KindCommitted si.Kind = snapshots.KindCommitted
si.Created = time.Now().UTC() si.Created = time.Now().UTC()
si.Updated = si.Created si.Updated = si.Created
@ -460,10 +460,10 @@ func parents(bkt, pbkt *bolt.Bucket, parent uint64) (parents []string, err error
} }
} }
func readKind(bkt *bolt.Bucket) (k snapshot.Kind) { func readKind(bkt *bolt.Bucket) (k snapshots.Kind) {
kind := bkt.Get(bucketKeyKind) kind := bkt.Get(bucketKeyKind)
if len(kind) == 1 { if len(kind) == 1 {
k = snapshot.Kind(kind[0]) k = snapshots.Kind(kind[0])
} }
return return
} }
@ -473,7 +473,7 @@ func readID(bkt *bolt.Bucket) uint64 {
return id return id
} }
func readSnapshot(bkt *bolt.Bucket, id *uint64, si *snapshot.Info) error { func readSnapshot(bkt *bolt.Bucket, id *uint64, si *snapshots.Info) error {
if id != nil { if id != nil {
*id = readID(bkt) *id = readID(bkt)
} }
@ -495,7 +495,7 @@ func readSnapshot(bkt *bolt.Bucket, id *uint64, si *snapshot.Info) error {
return nil return nil
} }
func putSnapshot(bkt *bolt.Bucket, id uint64, si snapshot.Info) error { func putSnapshot(bkt *bolt.Bucket, id uint64, si snapshots.Info) error {
idEncoded, err := encodeID(id) idEncoded, err := encodeID(id)
if err != nil { if err != nil {
return err return err
@ -519,12 +519,12 @@ func putSnapshot(bkt *bolt.Bucket, id uint64, si snapshot.Info) error {
return boltutil.WriteLabels(bkt, si.Labels) return boltutil.WriteLabels(bkt, si.Labels)
} }
func getUsage(bkt *bolt.Bucket, usage *snapshot.Usage) { func getUsage(bkt *bolt.Bucket, usage *snapshots.Usage) {
usage.Inodes, _ = binary.Varint(bkt.Get(bucketKeyInodes)) usage.Inodes, _ = binary.Varint(bkt.Get(bucketKeyInodes))
usage.Size, _ = binary.Varint(bkt.Get(bucketKeySize)) usage.Size, _ = binary.Varint(bkt.Get(bucketKeySize))
} }
func putUsage(bkt *bolt.Bucket, usage snapshot.Usage) error { func putUsage(bkt *bolt.Bucket, usage snapshots.Usage) error {
for _, v := range []struct { for _, v := range []struct {
key []byte key []byte
value int64 value int64

View File

@ -10,7 +10,7 @@ import (
"sync" "sync"
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -35,7 +35,7 @@ type Transactor interface {
// the last index. The last index should always be considered the active // the last index. The last index should always be considered the active
// snapshots immediate parent. // snapshots immediate parent.
type Snapshot struct { type Snapshot struct {
Kind snapshot.Kind Kind snapshots.Kind
ID string ID string
ParentIDs []string ParentIDs []string
} }

View File

@ -7,7 +7,7 @@ import (
"os" "os"
"testing" "testing"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
) )
// Benchmarks returns a benchmark suite using the provided metadata store // Benchmarks returns a benchmark suite using the provided metadata store
@ -106,14 +106,14 @@ func openCloseReadonly(b *testing.B, name string, metaFn metaFactory) func(b *te
} }
func createActiveFromBase(ctx context.Context, ms *MetaStore, active, base string) error { func createActiveFromBase(ctx context.Context, ms *MetaStore, active, base string) error {
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "bottom", ""); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "bottom", ""); err != nil {
return err return err
} }
if _, err := CommitActive(ctx, "bottom", base, snapshot.Usage{}); err != nil { if _, err := CommitActive(ctx, "bottom", base, snapshots.Usage{}); err != nil {
return err return err
} }
_, err := CreateSnapshot(ctx, snapshot.KindActive, active, base) _, err := CreateSnapshot(ctx, snapshots.KindActive, active, base)
return err return err
} }
@ -135,7 +135,7 @@ func statCommittedBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) {
if err := createActiveFromBase(ctx, ms, "active", "base"); err != nil { if err := createActiveFromBase(ctx, ms, "active", "base"); err != nil {
b.Fatal(err) b.Fatal(err)
} }
if _, err := CommitActive(ctx, "active", "committed", snapshot.Usage{}); err != nil { if _, err := CommitActive(ctx, "active", "committed", snapshots.Usage{}); err != nil {
b.Fatal(err) b.Fatal(err)
} }
@ -150,7 +150,7 @@ func statCommittedBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) {
func createActiveBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { func createActiveBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active", ""); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active", ""); err != nil {
b.Fatal(err) b.Fatal(err)
} }
b.StopTimer() b.StopTimer()
@ -164,7 +164,7 @@ func createActiveBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) {
func removeBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { func removeBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
b.StopTimer() b.StopTimer()
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active", ""); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active", ""); err != nil {
b.Fatal(err) b.Fatal(err)
} }
b.StartTimer() b.StartTimer()
@ -177,11 +177,11 @@ func removeBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) {
func commitBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { func commitBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) {
b.StopTimer() b.StopTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active", ""); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active", ""); err != nil {
b.Fatal(err) b.Fatal(err)
} }
b.StartTimer() b.StartTimer()
if _, err := CommitActive(ctx, "active", "committed", snapshot.Usage{}); err != nil { if _, err := CommitActive(ctx, "active", "committed", snapshots.Usage{}); err != nil {
b.Fatal(err) b.Fatal(err)
} }
b.StopTimer() b.StopTimer()
@ -194,17 +194,17 @@ func commitBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) {
func getActiveBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { func getActiveBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) {
var base string var base string
for i := 1; i <= 10; i++ { for i := 1; i <= 10; i++ {
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "tmp", base); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "tmp", base); err != nil {
b.Fatalf("create active failed: %+v", err) b.Fatalf("create active failed: %+v", err)
} }
base = fmt.Sprintf("base-%d", i) base = fmt.Sprintf("base-%d", i)
if _, err := CommitActive(ctx, "tmp", base, snapshot.Usage{}); err != nil { if _, err := CommitActive(ctx, "tmp", base, snapshots.Usage{}); err != nil {
b.Fatalf("commit failed: %+v", err) b.Fatalf("commit failed: %+v", err)
} }
} }
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active", base); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active", base); err != nil {
b.Fatalf("create active failed: %+v", err) b.Fatalf("create active failed: %+v", err)
} }
b.ResetTimer() b.ResetTimer()

View File

@ -9,7 +9,7 @@ import (
"time" "time"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -129,71 +129,71 @@ func inWriteTransaction(fn testFunc) testFunc {
// - "active-4": readonly active without parent" // - "active-4": readonly active without parent"
// - "active-5": readonly active with parent "committed-2" // - "active-5": readonly active with parent "committed-2"
func basePopulate(ctx context.Context, ms *MetaStore) error { func basePopulate(ctx context.Context, ms *MetaStore) error {
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "committed-tmp-1", ""); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "committed-tmp-1", ""); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
if _, err := CommitActive(ctx, "committed-tmp-1", "committed-1", snapshot.Usage{Size: 1}); err != nil { if _, err := CommitActive(ctx, "committed-tmp-1", "committed-1", snapshots.Usage{Size: 1}); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "committed-tmp-2", "committed-1"); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "committed-tmp-2", "committed-1"); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
if _, err := CommitActive(ctx, "committed-tmp-2", "committed-2", snapshot.Usage{Size: 2}); err != nil { if _, err := CommitActive(ctx, "committed-tmp-2", "committed-2", snapshots.Usage{Size: 2}); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", ""); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", ""); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active-2", "committed-1"); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-2", "committed-1"); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active-3", "committed-2"); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-3", "committed-2"); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
if _, err := CreateSnapshot(ctx, snapshot.KindView, "view-1", ""); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindView, "view-1", ""); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
if _, err := CreateSnapshot(ctx, snapshot.KindView, "view-2", "committed-2"); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindView, "view-2", "committed-2"); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
return nil return nil
} }
var baseInfo = map[string]snapshot.Info{ var baseInfo = map[string]snapshots.Info{
"committed-1": { "committed-1": {
Name: "committed-1", Name: "committed-1",
Parent: "", Parent: "",
Kind: snapshot.KindCommitted, Kind: snapshots.KindCommitted,
}, },
"committed-2": { "committed-2": {
Name: "committed-2", Name: "committed-2",
Parent: "committed-1", Parent: "committed-1",
Kind: snapshot.KindCommitted, Kind: snapshots.KindCommitted,
}, },
"active-1": { "active-1": {
Name: "active-1", Name: "active-1",
Parent: "", Parent: "",
Kind: snapshot.KindActive, Kind: snapshots.KindActive,
}, },
"active-2": { "active-2": {
Name: "active-2", Name: "active-2",
Parent: "committed-1", Parent: "committed-1",
Kind: snapshot.KindActive, Kind: snapshots.KindActive,
}, },
"active-3": { "active-3": {
Name: "active-3", Name: "active-3",
Parent: "committed-2", Parent: "committed-2",
Kind: snapshot.KindActive, Kind: snapshots.KindActive,
}, },
"view-1": { "view-1": {
Name: "view-1", Name: "view-1",
Parent: "", Parent: "",
Kind: snapshot.KindView, Kind: snapshots.KindView,
}, },
"view-2": { "view-2": {
Name: "view-2", Name: "view-2",
Parent: "committed-2", Parent: "committed-2",
Kind: snapshot.KindView, Kind: snapshots.KindView,
}, },
} }
@ -252,8 +252,8 @@ func testGetInfoNotExist(ctx context.Context, t *testing.T, ms *MetaStore) {
} }
func testWalk(ctx context.Context, t *testing.T, ms *MetaStore) { func testWalk(ctx context.Context, t *testing.T, ms *MetaStore) {
found := map[string]snapshot.Info{} found := map[string]snapshots.Info{}
err := WalkInfo(ctx, func(ctx context.Context, info snapshot.Info) error { err := WalkInfo(ctx, func(ctx context.Context, info snapshots.Info) error {
if _, ok := found[info.Name]; ok { if _, ok := found[info.Name]; ok {
return errors.Errorf("entry already encountered") return errors.Errorf("entry already encountered")
} }
@ -272,35 +272,35 @@ func testWalk(ctx context.Context, t *testing.T, ms *MetaStore) {
func testGetSnapshot(ctx context.Context, t *testing.T, ms *MetaStore) { func testGetSnapshot(ctx context.Context, t *testing.T, ms *MetaStore) {
snapshotMap := map[string]Snapshot{} snapshotMap := map[string]Snapshot{}
populate := func(ctx context.Context, ms *MetaStore) error { populate := func(ctx context.Context, ms *MetaStore) error {
if _, err := CreateSnapshot(ctx, snapshot.KindActive, "committed-tmp-1", ""); err != nil { if _, err := CreateSnapshot(ctx, snapshots.KindActive, "committed-tmp-1", ""); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
if _, err := CommitActive(ctx, "committed-tmp-1", "committed-1", snapshot.Usage{}); err != nil { if _, err := CommitActive(ctx, "committed-tmp-1", "committed-1", snapshots.Usage{}); err != nil {
return errors.Wrap(err, "failed to create active") return errors.Wrap(err, "failed to create active")
} }
for _, opts := range []struct { for _, opts := range []struct {
Kind snapshot.Kind Kind snapshots.Kind
Name string Name string
Parent string Parent string
}{ }{
{ {
Name: "active-1", Name: "active-1",
Kind: snapshot.KindActive, Kind: snapshots.KindActive,
}, },
{ {
Name: "active-2", Name: "active-2",
Parent: "committed-1", Parent: "committed-1",
Kind: snapshot.KindActive, Kind: snapshots.KindActive,
}, },
{ {
Name: "view-1", Name: "view-1",
Kind: snapshot.KindView, Kind: snapshots.KindView,
}, },
{ {
Name: "view-2", Name: "view-2",
Parent: "committed-1", Parent: "committed-1",
Kind: snapshot.KindView, Kind: snapshots.KindView,
}, },
} { } {
active, err := CreateSnapshot(ctx, opts.Kind, opts.Name, opts.Parent) active, err := CreateSnapshot(ctx, opts.Kind, opts.Name, opts.Parent)
@ -336,26 +336,26 @@ func testGetSnapshotNotExist(ctx context.Context, t *testing.T, ms *MetaStore) {
} }
func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) { func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) {
a1, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", "") a1, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", "")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if a1.Kind != snapshot.KindActive { if a1.Kind != snapshots.KindActive {
t.Fatal("Expected writable active") t.Fatal("Expected writable active")
} }
a2, err := CreateSnapshot(ctx, snapshot.KindView, "view-1", "") a2, err := CreateSnapshot(ctx, snapshots.KindView, "view-1", "")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if a2.ID == a1.ID { if a2.ID == a1.ID {
t.Fatal("Returned active identifiers must be unique") t.Fatal("Returned active identifiers must be unique")
} }
if a2.Kind != snapshot.KindView { if a2.Kind != snapshots.KindView {
t.Fatal("Expected a view") t.Fatal("Expected a view")
} }
commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshot.Usage{}) commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshots.Usage{})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -363,7 +363,7 @@ func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) {
t.Fatal("Snapshot identifier must not change on commit") t.Fatal("Snapshot identifier must not change on commit")
} }
a3, err := CreateSnapshot(ctx, snapshot.KindActive, "active-3", "committed-1") a3, err := CreateSnapshot(ctx, snapshots.KindActive, "active-3", "committed-1")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -376,11 +376,11 @@ func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) {
if a3.ParentIDs[0] != commitID { if a3.ParentIDs[0] != commitID {
t.Fatal("Expected active parent to be same as commit ID") t.Fatal("Expected active parent to be same as commit ID")
} }
if a3.Kind != snapshot.KindActive { if a3.Kind != snapshots.KindActive {
t.Fatal("Expected writable active") t.Fatal("Expected writable active")
} }
a4, err := CreateSnapshot(ctx, snapshot.KindView, "view-2", "committed-1") a4, err := CreateSnapshot(ctx, snapshots.KindView, "view-2", "committed-1")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -393,7 +393,7 @@ func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) {
if a3.ParentIDs[0] != commitID { if a3.ParentIDs[0] != commitID {
t.Fatal("Expected active parent to be same as commit ID") t.Fatal("Expected active parent to be same as commit ID")
} }
if a4.Kind != snapshot.KindView { if a4.Kind != snapshots.KindView {
t.Fatal("Expected a view") t.Fatal("Expected a view")
} }
} }
@ -402,14 +402,14 @@ func testCreateActiveExist(ctx context.Context, t *testing.T, ms *MetaStore) {
if err := basePopulate(ctx, ms); err != nil { if err := basePopulate(ctx, ms); err != nil {
t.Fatalf("Populate failed: %+v", err) t.Fatalf("Populate failed: %+v", err)
} }
_, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", "") _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", "")
assertExist(t, err) assertExist(t, err)
_, err = CreateSnapshot(ctx, snapshot.KindActive, "committed-1", "") _, err = CreateSnapshot(ctx, snapshots.KindActive, "committed-1", "")
assertExist(t, err) assertExist(t, err)
} }
func testCreateActiveNotExist(ctx context.Context, t *testing.T, ms *MetaStore) { func testCreateActiveNotExist(ctx context.Context, t *testing.T, ms *MetaStore) {
_, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", "does-not-exist") _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", "does-not-exist")
assertNotExist(t, err) assertNotExist(t, err)
} }
@ -417,20 +417,20 @@ func testCreateActiveFromActive(ctx context.Context, t *testing.T, ms *MetaStore
if err := basePopulate(ctx, ms); err != nil { if err := basePopulate(ctx, ms); err != nil {
t.Fatalf("Populate failed: %+v", err) t.Fatalf("Populate failed: %+v", err)
} }
_, err := CreateSnapshot(ctx, snapshot.KindActive, "active-new", "active-1") _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-new", "active-1")
assertNotCommitted(t, err) assertNotCommitted(t, err)
} }
func testCommit(ctx context.Context, t *testing.T, ms *MetaStore) { func testCommit(ctx context.Context, t *testing.T, ms *MetaStore) {
a1, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", "") a1, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", "")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if a1.Kind != snapshot.KindActive { if a1.Kind != snapshots.KindActive {
t.Fatal("Expected writable active") t.Fatal("Expected writable active")
} }
commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshot.Usage{}) commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshots.Usage{})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -448,7 +448,7 @@ func testCommitExist(ctx context.Context, t *testing.T, ms *MetaStore) {
if err := basePopulate(ctx, ms); err != nil { if err := basePopulate(ctx, ms); err != nil {
t.Fatalf("Populate failed: %+v", err) t.Fatalf("Populate failed: %+v", err)
} }
_, err := CommitActive(ctx, "active-1", "committed-1", snapshot.Usage{}) _, err := CommitActive(ctx, "active-1", "committed-1", snapshots.Usage{})
assertExist(t, err) assertExist(t, err)
} }
@ -456,7 +456,7 @@ func testCommitCommitted(ctx context.Context, t *testing.T, ms *MetaStore) {
if err := basePopulate(ctx, ms); err != nil { if err := basePopulate(ctx, ms); err != nil {
t.Fatalf("Populate failed: %+v", err) t.Fatalf("Populate failed: %+v", err)
} }
_, err := CommitActive(ctx, "committed-1", "committed-3", snapshot.Usage{}) _, err := CommitActive(ctx, "committed-1", "committed-3", snapshots.Usage{})
assertNotActive(t, err) assertNotActive(t, err)
} }
@ -464,19 +464,19 @@ func testCommitViewFails(ctx context.Context, t *testing.T, ms *MetaStore) {
if err := basePopulate(ctx, ms); err != nil { if err := basePopulate(ctx, ms); err != nil {
t.Fatalf("Populate failed: %+v", err) t.Fatalf("Populate failed: %+v", err)
} }
_, err := CommitActive(ctx, "view-1", "committed-3", snapshot.Usage{}) _, err := CommitActive(ctx, "view-1", "committed-3", snapshots.Usage{})
if err == nil { if err == nil {
t.Fatal("Expected error committing readonly active") t.Fatal("Expected error committing readonly active")
} }
} }
func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) { func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) {
a1, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", "") a1, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", "")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshot.Usage{}) commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshots.Usage{})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -484,12 +484,12 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) {
t.Fatal("Snapshot identifier must not change on commit") t.Fatal("Snapshot identifier must not change on commit")
} }
a2, err := CreateSnapshot(ctx, snapshot.KindView, "view-1", "committed-1") a2, err := CreateSnapshot(ctx, snapshots.KindView, "view-1", "committed-1")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
a3, err := CreateSnapshot(ctx, snapshot.KindView, "view-2", "committed-1") a3, err := CreateSnapshot(ctx, snapshots.KindView, "view-2", "committed-1")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -504,7 +504,7 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) {
if r3 != a3.ID { if r3 != a3.ID {
t.Fatal("Expected remove ID to match create ID") t.Fatal("Expected remove ID to match create ID")
} }
if k3 != snapshot.KindView { if k3 != snapshots.KindView {
t.Fatalf("Expected view kind, got %v", k3) t.Fatalf("Expected view kind, got %v", k3)
} }
@ -515,7 +515,7 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) {
if r2 != a2.ID { if r2 != a2.ID {
t.Fatal("Expected remove ID to match create ID") t.Fatal("Expected remove ID to match create ID")
} }
if k2 != snapshot.KindView { if k2 != snapshots.KindView {
t.Fatalf("Expected view kind, got %v", k2) t.Fatalf("Expected view kind, got %v", k2)
} }
@ -526,7 +526,7 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) {
if r1 != commitID { if r1 != commitID {
t.Fatal("Expected remove ID to match commit ID") t.Fatal("Expected remove ID to match commit ID")
} }
if k1 != snapshot.KindCommitted { if k1 != snapshots.KindCommitted {
t.Fatalf("Expected committed kind, got %v", k1) t.Fatalf("Expected committed kind, got %v", k1)
} }
} }
@ -581,10 +581,10 @@ func testParents(ctx context.Context, t *testing.T, ms *MetaStore) {
id string id string
parents []string parents []string
) )
if info.Kind == snapshot.KindCommitted { if info.Kind == snapshots.KindCommitted {
// When commited, create view and resolve from view // When commited, create view and resolve from view
nid := fmt.Sprintf("test-%s-%d", tc.Name, i) nid := fmt.Sprintf("test-%s-%d", tc.Name, i)
s, err := CreateSnapshot(ctx, snapshot.KindView, nid, name) s, err := CreateSnapshot(ctx, snapshots.KindView, nid, name)
if err != nil { if err != nil {
t.Fatalf("Failed to get snapshot %s: %v", tc.Name, err) t.Fatalf("Failed to get snapshot %s: %v", tc.Name, err)
} }

View File

@ -9,7 +9,7 @@ import (
"github.com/containerd/containerd/fs/fstest" "github.com/containerd/containerd/fs/fstest"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -34,7 +34,7 @@ func applyToMounts(m []mount.Mount, work string, a fstest.Applier) (err error) {
// createSnapshot creates a new snapshot in the snapshotter // createSnapshot creates a new snapshot in the snapshotter
// given an applier to run on top of the given parent. // given an applier to run on top of the given parent.
func createSnapshot(ctx context.Context, sn snapshot.Snapshotter, parent, work string, a fstest.Applier) (string, error) { func createSnapshot(ctx context.Context, sn snapshots.Snapshotter, parent, work string, a fstest.Applier) (string, error) {
n := fmt.Sprintf("%p-%d", a, rand.Int()) n := fmt.Sprintf("%p-%d", a, rand.Int())
prepare := fmt.Sprintf("%s-prepare", n) prepare := fmt.Sprintf("%s-prepare", n)
@ -54,7 +54,7 @@ func createSnapshot(ctx context.Context, sn snapshot.Snapshotter, parent, work s
return n, nil return n, nil
} }
func checkSnapshot(ctx context.Context, sn snapshot.Snapshotter, work, name, check string) (err error) { func checkSnapshot(ctx context.Context, sn snapshots.Snapshotter, work, name, check string) (err error) {
td, err := ioutil.TempDir(work, "check") td, err := ioutil.TempDir(work, "check")
if err != nil { if err != nil {
return errors.Wrap(err, "failed to create temp dir") return errors.Wrap(err, "failed to create temp dir")
@ -95,7 +95,7 @@ func checkSnapshot(ctx context.Context, sn snapshot.Snapshotter, work, name, che
// checkSnapshots creates a new chain of snapshots in the given snapshotter // checkSnapshots creates a new chain of snapshots in the given snapshotter
// using the provided appliers, checking each snapshot created in a view // using the provided appliers, checking each snapshot created in a view
// against the changes applied to a single directory. // against the changes applied to a single directory.
func checkSnapshots(ctx context.Context, sn snapshot.Snapshotter, work string, as ...fstest.Applier) error { func checkSnapshots(ctx context.Context, sn snapshots.Snapshotter, work string, as ...fstest.Applier) error {
td, err := ioutil.TempDir(work, "flat") td, err := ioutil.TempDir(work, "flat")
if err != nil { if err != nil {
return errors.Wrap(err, "failed to create temp dir") return errors.Wrap(err, "failed to create temp dir")
@ -124,7 +124,7 @@ func checkSnapshots(ctx context.Context, sn snapshot.Snapshotter, work string, a
} }
// checkInfo checks that the infos are the same // checkInfo checks that the infos are the same
func checkInfo(si1, si2 snapshot.Info) error { func checkInfo(si1, si2 snapshots.Info) error {
if si1.Kind != si2.Kind { if si1.Kind != si2.Kind {
return errors.Errorf("Expected kind %v, got %v", si1.Kind, si2.Kind) return errors.Errorf("Expected kind %v, got %v", si1.Kind, si2.Kind)
} }

View File

@ -8,7 +8,7 @@ import (
"time" "time"
"github.com/containerd/containerd/fs/fstest" "github.com/containerd/containerd/fs/fstest"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
) )
// Checks which cover former issues found in older layering models. // Checks which cover former issues found in older layering models.
@ -23,7 +23,7 @@ import (
// Cause of issue was originally related to tar, snapshot should be able to // Cause of issue was originally related to tar, snapshot should be able to
// avoid such issues by not relying on tar to create layers. // avoid such issues by not relying on tar to create layers.
// See https://github.com/docker/docker/issues/21555 // See https://github.com/docker/docker/issues/21555
func checkLayerFileUpdate(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { func checkLayerFileUpdate(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) {
l1Init := fstest.Apply( l1Init := fstest.Apply(
fstest.CreateDir("/etc", 0700), fstest.CreateDir("/etc", 0700),
fstest.CreateFile("/etc/hosts", []byte("mydomain 10.0.0.1"), 0644), fstest.CreateFile("/etc/hosts", []byte("mydomain 10.0.0.1"), 0644),
@ -54,7 +54,7 @@ func checkLayerFileUpdate(ctx context.Context, t *testing.T, sn snapshot.Snapsho
// checkRemoveDirectoryInLowerLayer // checkRemoveDirectoryInLowerLayer
// See https://github.com/docker/docker/issues/25244 // See https://github.com/docker/docker/issues/25244
func checkRemoveDirectoryInLowerLayer(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { func checkRemoveDirectoryInLowerLayer(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) {
l1Init := fstest.Apply( l1Init := fstest.Apply(
fstest.CreateDir("/lib", 0700), fstest.CreateDir("/lib", 0700),
fstest.CreateFile("/lib/hidden", []byte{}, 0644), fstest.CreateFile("/lib/hidden", []byte{}, 0644),
@ -77,7 +77,7 @@ func checkRemoveDirectoryInLowerLayer(ctx context.Context, t *testing.T, sn snap
// See https://github.com/docker/docker/issues/20240 aufs // See https://github.com/docker/docker/issues/20240 aufs
// See https://github.com/docker/docker/issues/24913 overlay // See https://github.com/docker/docker/issues/24913 overlay
// see https://github.com/docker/docker/issues/28391 overlay2 // see https://github.com/docker/docker/issues/28391 overlay2
func checkChown(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { func checkChown(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) {
l1Init := fstest.Apply( l1Init := fstest.Apply(
fstest.CreateDir("/opt", 0700), fstest.CreateDir("/opt", 0700),
fstest.CreateDir("/opt/a", 0700), fstest.CreateDir("/opt/a", 0700),
@ -98,7 +98,7 @@ func checkChown(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work
// checkRename // checkRename
// https://github.com/docker/docker/issues/25409 // https://github.com/docker/docker/issues/25409
func checkRename(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { func checkRename(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) {
t.Skip("rename test still fails on some kernels with overlay") t.Skip("rename test still fails on some kernels with overlay")
l1Init := fstest.Apply( l1Init := fstest.Apply(
fstest.CreateDir("/dir1", 0700), fstest.CreateDir("/dir1", 0700),
@ -120,7 +120,7 @@ func checkRename(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, wor
// checkDirectoryPermissionOnCommit // checkDirectoryPermissionOnCommit
// https://github.com/docker/docker/issues/27298 // https://github.com/docker/docker/issues/27298
func checkDirectoryPermissionOnCommit(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { func checkDirectoryPermissionOnCommit(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) {
l1Init := fstest.Apply( l1Init := fstest.Apply(
fstest.CreateDir("/dir1", 0700), fstest.CreateDir("/dir1", 0700),
fstest.CreateDir("/dir2", 0700), fstest.CreateDir("/dir2", 0700),
@ -155,13 +155,13 @@ func checkDirectoryPermissionOnCommit(ctx context.Context, t *testing.T, sn snap
} }
// checkStatInWalk ensures that a stat can be called during a walk // checkStatInWalk ensures that a stat can be called during a walk
func checkStatInWalk(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { func checkStatInWalk(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) {
prefix := "stats-in-walk-" prefix := "stats-in-walk-"
if err := createNamedSnapshots(ctx, sn, prefix); err != nil { if err := createNamedSnapshots(ctx, sn, prefix); err != nil {
t.Fatal(err) t.Fatal(err)
} }
err := sn.Walk(ctx, func(ctx context.Context, si snapshot.Info) error { err := sn.Walk(ctx, func(ctx context.Context, si snapshots.Info) error {
if !strings.HasPrefix(si.Name, prefix) { if !strings.HasPrefix(si.Name, prefix) {
// Only stat snapshots from this test // Only stat snapshots from this test
return nil return nil
@ -178,7 +178,7 @@ func checkStatInWalk(ctx context.Context, t *testing.T, sn snapshot.Snapshotter,
} }
} }
func createNamedSnapshots(ctx context.Context, snapshotter snapshot.Snapshotter, ns string) error { func createNamedSnapshots(ctx context.Context, snapshotter snapshots.Snapshotter, ns string) error {
c1 := fmt.Sprintf("%sc1", ns) c1 := fmt.Sprintf("%sc1", ns)
c2 := fmt.Sprintf("%sc2", ns) c2 := fmt.Sprintf("%sc2", ns)
if _, err := snapshotter.Prepare(ctx, c1+"-a", "", opt); err != nil { if _, err := snapshotter.Prepare(ctx, c1+"-a", "", opt); err != nil {

View File

@ -13,13 +13,13 @@ import (
"github.com/containerd/containerd/fs/fstest" "github.com/containerd/containerd/fs/fstest"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/testutil" "github.com/containerd/containerd/testutil"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
// SnapshotterSuite runs a test suite on the snapshotter given a factory function. // SnapshotterSuite runs a test suite on the snapshotter given a factory function.
func SnapshotterSuite(t *testing.T, name string, snapshotterFn func(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error)) { func SnapshotterSuite(t *testing.T, name string, snapshotterFn func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error)) {
restoreMask := clearMask() restoreMask := clearMask()
defer restoreMask() defer restoreMask()
@ -46,7 +46,7 @@ func SnapshotterSuite(t *testing.T, name string, snapshotterFn func(ctx context.
t.Run("CloseTwice", makeTest(name, snapshotterFn, closeTwice)) t.Run("CloseTwice", makeTest(name, snapshotterFn, closeTwice))
} }
func makeTest(name string, snapshotterFn func(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error), fn func(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string)) func(t *testing.T) { func makeTest(name string, snapshotterFn func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error), fn func(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string)) func(t *testing.T) {
return func(t *testing.T) { return func(t *testing.T) {
t.Parallel() t.Parallel()
@ -91,12 +91,12 @@ func makeTest(name string, snapshotterFn func(ctx context.Context, root string)
} }
} }
var opt = snapshot.WithLabels(map[string]string{ var opt = snapshots.WithLabels(map[string]string{
"containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339), "containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339),
}) })
// checkSnapshotterBasic tests the basic workflow of a snapshot snapshotter. // checkSnapshotterBasic tests the basic workflow of a snapshot snapshotter.
func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
initialApplier := fstest.Apply( initialApplier := fstest.Apply(
fstest.CreateFile("/foo", []byte("foo\n"), 0777), fstest.CreateFile("/foo", []byte("foo\n"), 0777),
fstest.CreateDir("/a", 0755), fstest.CreateDir("/a", 0755),
@ -145,7 +145,7 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
} }
assert.Equal(t, "", si.Parent) assert.Equal(t, "", si.Parent)
assert.Equal(t, snapshot.KindCommitted, si.Kind) assert.Equal(t, snapshots.KindCommitted, si.Kind)
_, err = snapshotter.Stat(ctx, preparing) _, err = snapshotter.Stat(ctx, preparing)
if err == nil { if err == nil {
@ -180,7 +180,7 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
} }
assert.Equal(t, committed, ni.Parent) assert.Equal(t, committed, ni.Parent)
assert.Equal(t, snapshot.KindActive, ni.Kind) assert.Equal(t, snapshots.KindActive, ni.Kind)
nextCommitted := filepath.Join(work, "committed-next") nextCommitted := filepath.Join(work, "committed-next")
if err := snapshotter.Commit(ctx, nextCommitted, next, opt); err != nil { if err := snapshotter.Commit(ctx, nextCommitted, next, opt); err != nil {
@ -193,19 +193,19 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
} }
assert.Equal(t, committed, si2.Parent) assert.Equal(t, committed, si2.Parent)
assert.Equal(t, snapshot.KindCommitted, si2.Kind) assert.Equal(t, snapshots.KindCommitted, si2.Kind)
_, err = snapshotter.Stat(ctx, next) _, err = snapshotter.Stat(ctx, next)
if err == nil { if err == nil {
t.Fatalf("%s should no longer be available after Commit", next) t.Fatalf("%s should no longer be available after Commit", next)
} }
expected := map[string]snapshot.Info{ expected := map[string]snapshots.Info{
si.Name: si, si.Name: si,
si2.Name: si2, si2.Name: si2,
} }
walked := map[string]snapshot.Info{} // walk is not ordered walked := map[string]snapshots.Info{} // walk is not ordered
assert.NoError(t, snapshotter.Walk(ctx, func(ctx context.Context, si snapshot.Info) error { assert.NoError(t, snapshotter.Walk(ctx, func(ctx context.Context, si snapshots.Info) error {
walked[si.Name] = si walked[si.Name] = si
return nil return nil
})) }))
@ -246,7 +246,7 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
} }
// Create a New Layer on top of base layer with Prepare, Stat on new layer, should return Active layer. // Create a New Layer on top of base layer with Prepare, Stat on new layer, should return Active layer.
func checkSnapshotterStatActive(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkSnapshotterStatActive(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
preparing := filepath.Join(work, "preparing") preparing := filepath.Join(work, "preparing")
if err := os.MkdirAll(preparing, 0777); err != nil { if err := os.MkdirAll(preparing, 0777); err != nil {
t.Fatal(err) t.Fatal(err)
@ -275,12 +275,12 @@ func checkSnapshotterStatActive(ctx context.Context, t *testing.T, snapshotter s
t.Fatal(err) t.Fatal(err)
} }
assert.Equal(t, si.Name, preparing) assert.Equal(t, si.Name, preparing)
assert.Equal(t, snapshot.KindActive, si.Kind) assert.Equal(t, snapshots.KindActive, si.Kind)
assert.Equal(t, "", si.Parent) assert.Equal(t, "", si.Parent)
} }
// Commit a New Layer on top of base layer with Prepare & Commit , Stat on new layer, should return Committed layer. // Commit a New Layer on top of base layer with Prepare & Commit , Stat on new layer, should return Committed layer.
func checkSnapshotterStatCommitted(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkSnapshotterStatCommitted(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
preparing := filepath.Join(work, "preparing") preparing := filepath.Join(work, "preparing")
if err := os.MkdirAll(preparing, 0777); err != nil { if err := os.MkdirAll(preparing, 0777); err != nil {
t.Fatal(err) t.Fatal(err)
@ -314,12 +314,12 @@ func checkSnapshotterStatCommitted(ctx context.Context, t *testing.T, snapshotte
t.Fatal(err) t.Fatal(err)
} }
assert.Equal(t, si.Name, committed) assert.Equal(t, si.Name, committed)
assert.Equal(t, snapshot.KindCommitted, si.Kind) assert.Equal(t, snapshots.KindCommitted, si.Kind)
assert.Equal(t, "", si.Parent) assert.Equal(t, "", si.Parent)
} }
func snapshotterPrepareMount(ctx context.Context, snapshotter snapshot.Snapshotter, diffPathName string, parent string, work string) (string, error) { func snapshotterPrepareMount(ctx context.Context, snapshotter snapshots.Snapshotter, diffPathName string, parent string, work string) (string, error) {
preparing := filepath.Join(work, diffPathName) preparing := filepath.Join(work, diffPathName)
if err := os.MkdirAll(preparing, 0777); err != nil { if err := os.MkdirAll(preparing, 0777); err != nil {
return "", err return "", err
@ -341,7 +341,7 @@ func snapshotterPrepareMount(ctx context.Context, snapshotter snapshot.Snapshott
} }
// Given A <- B <- C, B is the parent of C and A is a transitive parent of C (in this case, a "grandparent") // Given A <- B <- C, B is the parent of C and A is a transitive parent of C (in this case, a "grandparent")
func checkSnapshotterTransitivity(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkSnapshotterTransitivity(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
preparing, err := snapshotterPrepareMount(ctx, snapshotter, "preparing", "", work) preparing, err := snapshotterPrepareMount(ctx, snapshotter, "preparing", "", work)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -395,7 +395,7 @@ func checkSnapshotterTransitivity(ctx context.Context, t *testing.T, snapshotter
} }
// Creating two layers with Prepare or View with same key must fail. // Creating two layers with Prepare or View with same key must fail.
func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
preparing, err := snapshotterPrepareMount(ctx, snapshotter, "preparing", "", work) preparing, err := snapshotterPrepareMount(ctx, snapshotter, "preparing", "", work)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -456,7 +456,7 @@ func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter
} }
// Deletion of files/folder of base layer in new layer, On Commit, those files should not be visible. // Deletion of files/folder of base layer in new layer, On Commit, those files should not be visible.
func checkDeletedFilesInChildSnapshot(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkDeletedFilesInChildSnapshot(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
l1Init := fstest.Apply( l1Init := fstest.Apply(
fstest.CreateFile("/foo", []byte("foo\n"), 0777), fstest.CreateFile("/foo", []byte("foo\n"), 0777),
@ -474,7 +474,7 @@ func checkDeletedFilesInChildSnapshot(ctx context.Context, t *testing.T, snapsho
} }
//Create three layers. Deleting intermediate layer must fail. //Create three layers. Deleting intermediate layer must fail.
func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
base, err := snapshotterPrepareMount(ctx, snapshotter, "base", "", work) base, err := snapshotterPrepareMount(ctx, snapshotter, "base", "", work)
if err != nil { if err != nil {
@ -533,7 +533,7 @@ func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshot
// a1 - active snapshot, no parent // a1 - active snapshot, no parent
// v1 - view snapshot, v1 is parent // v1 - view snapshot, v1 is parent
// v2 - view snapshot, no parent // v2 - view snapshot, no parent
func baseTestSnapshots(ctx context.Context, snapshotter snapshot.Snapshotter) error { func baseTestSnapshots(ctx context.Context, snapshotter snapshots.Snapshotter) error {
if _, err := snapshotter.Prepare(ctx, "c1-a", "", opt); err != nil { if _, err := snapshotter.Prepare(ctx, "c1-a", "", opt); err != nil {
return err return err
} }
@ -561,7 +561,7 @@ func baseTestSnapshots(ctx context.Context, snapshotter snapshot.Snapshotter) er
return nil return nil
} }
func checkUpdate(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkUpdate(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
t1 := time.Now().UTC() t1 := time.Now().UTC()
if err := baseTestSnapshots(ctx, snapshotter); err != nil { if err := baseTestSnapshots(ctx, snapshotter); err != nil {
t.Fatalf("Failed to create base snapshots: %v", err) t.Fatalf("Failed to create base snapshots: %v", err)
@ -569,35 +569,35 @@ func checkUpdate(ctx context.Context, t *testing.T, snapshotter snapshot.Snapsho
t2 := time.Now().UTC() t2 := time.Now().UTC()
testcases := []struct { testcases := []struct {
name string name string
kind snapshot.Kind kind snapshots.Kind
parent string parent string
}{ }{
{ {
name: "c1", name: "c1",
kind: snapshot.KindCommitted, kind: snapshots.KindCommitted,
}, },
{ {
name: "c2", name: "c2",
kind: snapshot.KindCommitted, kind: snapshots.KindCommitted,
parent: "c1", parent: "c1",
}, },
{ {
name: "a1", name: "a1",
kind: snapshot.KindActive, kind: snapshots.KindActive,
parent: "c2", parent: "c2",
}, },
{ {
name: "a2", name: "a2",
kind: snapshot.KindActive, kind: snapshots.KindActive,
}, },
{ {
name: "v1", name: "v1",
kind: snapshot.KindView, kind: snapshots.KindView,
parent: "c2", parent: "c2",
}, },
{ {
name: "v2", name: "v2",
kind: snapshot.KindView, kind: snapshots.KindView,
}, },
} }
for _, tc := range testcases { for _, tc := range testcases {
@ -717,7 +717,7 @@ func assertLabels(t *testing.T, actual, expected map[string]string) {
} }
} }
func checkRemove(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkRemove(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
if _, err := snapshotter.Prepare(ctx, "committed-a", "", opt); err != nil { if _, err := snapshotter.Prepare(ctx, "committed-a", "", opt); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -749,7 +749,7 @@ func checkRemove(ctx context.Context, t *testing.T, snapshotter snapshot.Snapsho
// checkSnapshotterViewReadonly ensures a KindView snapshot to be mounted as a read-only filesystem. // checkSnapshotterViewReadonly ensures a KindView snapshot to be mounted as a read-only filesystem.
// This function is called only when WithTestViewReadonly is true. // This function is called only when WithTestViewReadonly is true.
func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
preparing := filepath.Join(work, "preparing") preparing := filepath.Join(work, "preparing")
if _, err := snapshotter.Prepare(ctx, preparing, "", opt); err != nil { if _, err := snapshotter.Prepare(ctx, preparing, "", opt); err != nil {
t.Fatal(err) t.Fatal(err)
@ -786,7 +786,7 @@ func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter
// Move files from base layer to new location in intermediate layer. // Move files from base layer to new location in intermediate layer.
// Verify if the file at source is deleted and copied to new location. // Verify if the file at source is deleted and copied to new location.
func checkFileFromLowerLayer(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func checkFileFromLowerLayer(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
l1Init := fstest.Apply( l1Init := fstest.Apply(
fstest.CreateDir("/dir1", 0700), fstest.CreateDir("/dir1", 0700),
fstest.CreateFile("/dir1/f1", []byte("Hello"), 0644), fstest.CreateFile("/dir1/f1", []byte("Hello"), 0644),
@ -806,7 +806,7 @@ func checkFileFromLowerLayer(ctx context.Context, t *testing.T, snapshotter snap
} }
} }
func closeTwice(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { func closeTwice(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
// do some dummy ops to modify the snapshotter internal state // do some dummy ops to modify the snapshotter internal state
if _, err := snapshotter.Prepare(ctx, "dummy", ""); err != nil { if _, err := snapshotter.Prepare(ctx, "dummy", ""); err != nil {
t.Fatal(err) t.Fatal(err)

View File

@ -7,7 +7,7 @@ import (
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshots"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -31,7 +31,7 @@ type snapshotter struct {
} }
// NewSnapshotter returns a new windows snapshotter // NewSnapshotter returns a new windows snapshotter
func NewSnapshotter(root string) (snapshot.Snapshotter, error) { func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
return &snapshotter{ return &snapshotter{
root: root, root: root,
}, nil }, nil
@ -42,23 +42,23 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
// //
// Should be used for parent resolution, existence checks and to discern // Should be used for parent resolution, existence checks and to discern
// the kind of snapshot. // the kind of snapshot.
func (o *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { func (o *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) {
panic("not implemented") panic("not implemented")
} }
func (o *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { func (o *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
panic("not implemented") panic("not implemented")
} }
func (o *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { func (o *snapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) {
panic("not implemented") panic("not implemented")
} }
func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
panic("not implemented") panic("not implemented")
} }
func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
panic("not implemented") panic("not implemented")
} }
@ -70,7 +70,7 @@ func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er
panic("not implemented") panic("not implemented")
} }
func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
panic("not implemented") panic("not implemented")
} }
@ -81,7 +81,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) error {
} }
// Walk the committed snapshots. // Walk the committed snapshots.
func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
panic("not implemented") panic("not implemented")
} }