Merge pull request #807 from estesp/add-pause-resume

Add pause/resume implementation
This commit is contained in:
Michael Crosby
2017-05-08 10:15:58 -07:00
committed by GitHub
17 changed files with 512 additions and 63 deletions

View File

@@ -59,6 +59,8 @@ containerd client
killCommand,
pprofCommand,
execCommand,
pauseCommand,
resumeCommand,
}
app.Commands = append(app.Commands, extraCmds...)
app.Before = func(context *cli.Context) error {

29
cmd/ctr/pause.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import (
gocontext "context"
"errors"
"github.com/containerd/containerd/api/services/execution"
"github.com/urfave/cli"
)
var pauseCommand = cli.Command{
Name: "pause",
Usage: "pause an existing container",
ArgsUsage: "CONTAINER",
Action: func(context *cli.Context) error {
containers, err := getExecutionService(context)
if err != nil {
return err
}
id := context.Args().First()
if id == "" {
return errors.New("container id must be provided")
}
_, err = containers.Pause(gocontext.Background(), &execution.PauseRequest{
ID: id,
})
return err
},
}

29
cmd/ctr/resume.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import (
gocontext "context"
"errors"
"github.com/containerd/containerd/api/services/execution"
"github.com/urfave/cli"
)
var resumeCommand = cli.Command{
Name: "resume",
Usage: "resume a paused container",
ArgsUsage: "CONTAINER",
Action: func(context *cli.Context) error {
containers, err := getExecutionService(context)
if err != nil {
return err
}
id := context.Args().First()
if id == "" {
return errors.New("container id must be provided")
}
_, err = containers.Resume(gocontext.Background(), &execution.ResumeRequest{
ID: id,
})
return err
},
}