Add support for specifying a checkpoint directory. (#245)
Signed-off-by: Ross Boucher <rboucher@gmail.com>
This commit is contained in:
parent
76dd6710dc
commit
e756ae42d1
10 changed files with 291 additions and 228 deletions
|
@ -35,6 +35,13 @@ var listCheckpointCommand = cli.Command{
|
|||
Name: "list",
|
||||
Usage: "list all checkpoints for a container",
|
||||
Action: listCheckpoints,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "checkpoint-dir",
|
||||
Value: "",
|
||||
Usage: "path to checkpoint directory",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func listCheckpoints(context *cli.Context) {
|
||||
|
@ -47,6 +54,7 @@ func listCheckpoints(context *cli.Context) {
|
|||
}
|
||||
resp, err := c.ListCheckpoint(netcontext.Background(), &types.ListCheckpointRequest{
|
||||
Id: id,
|
||||
CheckpointDir: context.String("checkpoint-dir"),
|
||||
})
|
||||
if err != nil {
|
||||
fatal(err.Error(), 1)
|
||||
|
@ -81,6 +89,11 @@ var createCheckpointCommand = cli.Command{
|
|||
Name: "shell",
|
||||
Usage: "checkpoint shell jobs",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "checkpoint-dir",
|
||||
Value: "",
|
||||
Usage: "directory to store checkpoints",
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) {
|
||||
var (
|
||||
|
@ -96,6 +109,7 @@ var createCheckpointCommand = cli.Command{
|
|||
c := getClient(context)
|
||||
if _, err := c.CreateCheckpoint(netcontext.Background(), &types.CreateCheckpointRequest{
|
||||
Id: containerID,
|
||||
CheckpointDir: context.String("checkpoint-dir"),
|
||||
Checkpoint: &types.Checkpoint{
|
||||
Name: name,
|
||||
Exit: context.Bool("exit"),
|
||||
|
@ -112,6 +126,13 @@ var createCheckpointCommand = cli.Command{
|
|||
var deleteCheckpointCommand = cli.Command{
|
||||
Name: "delete",
|
||||
Usage: "delete a container's checkpoint",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "checkpoint-dir",
|
||||
Value: "",
|
||||
Usage: "path to checkpoint directory",
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) {
|
||||
var (
|
||||
containerID = context.Args().Get(0)
|
||||
|
@ -125,8 +146,9 @@ var deleteCheckpointCommand = cli.Command{
|
|||
}
|
||||
c := getClient(context)
|
||||
if _, err := c.DeleteCheckpoint(netcontext.Background(), &types.DeleteCheckpointRequest{
|
||||
Id: containerID,
|
||||
Name: name,
|
||||
Id: containerID,
|
||||
Name: name,
|
||||
CheckpointDir: context.String("checkpoint-dir"),
|
||||
}); err != nil {
|
||||
fatal(err.Error(), 1)
|
||||
}
|
||||
|
|
|
@ -134,6 +134,11 @@ var startCommand = cli.Command{
|
|||
Value: "",
|
||||
Usage: "checkpoint to start the container from",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "checkpoint-dir",
|
||||
Value: "",
|
||||
Usage: "path to checkpoint directory",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "attach,a",
|
||||
Usage: "connect to the stdio of the container",
|
||||
|
@ -177,14 +182,15 @@ var startCommand = cli.Command{
|
|||
tty bool
|
||||
c = getClient(context)
|
||||
r = &types.CreateContainerRequest{
|
||||
Id: id,
|
||||
BundlePath: bpath,
|
||||
Checkpoint: context.String("checkpoint"),
|
||||
Stdin: s.stdin,
|
||||
Stdout: s.stdout,
|
||||
Stderr: s.stderr,
|
||||
Labels: context.StringSlice("label"),
|
||||
NoPivotRoot: context.Bool("no-pivot"),
|
||||
Id: id,
|
||||
BundlePath: bpath,
|
||||
Checkpoint: context.String("checkpoint"),
|
||||
CheckpointDir: context.String("checkpoint-dir"),
|
||||
Stdin: s.stdin,
|
||||
Stdout: s.stdout,
|
||||
Stderr: s.stderr,
|
||||
Labels: context.StringSlice("label"),
|
||||
NoPivotRoot: context.Bool("no-pivot"),
|
||||
}
|
||||
)
|
||||
restoreAndCloseStdin = func() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue