Merge pull request #1167 from crosbymichael/multi-ss

support using multiple snapshotters simultaneously
This commit is contained in:
Derek McGowan
2017-07-12 13:34:31 -07:00
committed by GitHub
22 changed files with 743 additions and 255 deletions

View File

@@ -48,7 +48,7 @@ var runCommand = cli.Command{
Name: "run",
Usage: "run a container",
ArgsUsage: "IMAGE ID [COMMAND] [ARG...]",
Flags: []cli.Flag{
Flags: append([]cli.Flag{
cli.BoolFlag{
Name: "tty,t",
Usage: "allocate a TTY for the container",
@@ -86,7 +86,7 @@ var runCommand = cli.Command{
Name: "checkpoint",
Usage: "provide the checkpoint digest to restore the container",
},
},
}, snapshotterFlags...),
Action: func(context *cli.Context) error {
var (
err error

View File

@@ -106,6 +106,7 @@ func newContainer(ctx gocontext.Context, client *containerd.Client, context *cli
containerd.WithSpec(spec),
containerd.WithImage(image),
containerd.WithContainerLabels(labels),
containerd.WithSnapshotter(context.String("snapshotter")),
rootfs,
)
}

View File

@@ -19,6 +19,7 @@ import (
var snapshotCommand = cli.Command{
Name: "snapshot",
Usage: "snapshot management",
Flags: snapshotterFlags,
Subcommands: cli.Commands{
archiveSnapshotCommand,
listSnapshotCommand,
@@ -79,13 +80,11 @@ var listSnapshotCommand = cli.Command{
ctx, cancel := appContext(clicontext)
defer cancel()
client, err := newClient(clicontext)
snapshotter, err := getSnapshotter(clicontext)
if err != nil {
return err
}
snapshotter := client.SnapshotService()
tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0)
fmt.Fprintln(tw, "ID\tParent\tState\tReadonly\t")
@@ -125,11 +124,6 @@ var usageSnapshotCommand = cli.Command{
ctx, cancel := appContext(clicontext)
defer cancel()
client, err := newClient(clicontext)
if err != nil {
return err
}
var displaySize func(int64) string
if clicontext.Bool("b") {
displaySize = func(s int64) string {
@@ -141,7 +135,10 @@ var usageSnapshotCommand = cli.Command{
}
}
snapshotter := client.SnapshotService()
snapshotter, err := getSnapshotter(clicontext)
if err != nil {
return err
}
tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0)
fmt.Fprintln(tw, "ID\tSize\tInodes\t")
@@ -180,13 +177,11 @@ var removeSnapshotCommand = cli.Command{
ctx, cancel := appContext(clicontext)
defer cancel()
client, err := newClient(clicontext)
snapshotter, err := getSnapshotter(clicontext)
if err != nil {
return err
}
snapshotter := client.SnapshotService()
for _, id := range clicontext.Args() {
err = snapshotter.Remove(ctx, id)
if err != nil {
@@ -219,12 +214,11 @@ var prepareSnapshotCommand = cli.Command{
logrus.Infof("preparing mounts %s", dgst.String())
client, err := newClient(clicontext)
snapshotter, err := getSnapshotter(clicontext)
if err != nil {
return err
}
snapshotter := client.SnapshotService()
mounts, err := snapshotter.Prepare(ctx, target, dgst.String())
if err != nil {
return err

View File

@@ -35,6 +35,13 @@ import (
"google.golang.org/grpc"
)
var snapshotterFlags = []cli.Flag{
cli.StringFlag{
Name: "snapshotter",
Usage: "Snapshotter name. Empty value stands for the daemon default value.",
},
}
var grpcConn *grpc.ClientConn
// appContext returns the context for a command. Should only be called once per
@@ -111,7 +118,7 @@ func getSnapshotter(context *cli.Context) (snapshot.Snapshotter, error) {
if err != nil {
return nil, err
}
return snapshotservice.NewSnapshotterFromClient(snapshotapi.NewSnapshotsClient(conn)), nil
return snapshotservice.NewSnapshotterFromClient(snapshotapi.NewSnapshotsClient(conn), context.GlobalString("snapshotter")), nil
}
func getImageStore(clicontext *cli.Context) (images.Store, error) {