Merge pull request #457 from crosbymichael/update-go-runc
Update go-runc to afca56d262e694d9056e937a0877a39ab879aeb4
This commit is contained in:
commit
8228996a4a
3 changed files with 67 additions and 29 deletions
|
@ -1,5 +1,5 @@
|
||||||
# go-runc client for runc; master as of 12/16/2016
|
# go-runc client for runc; master as of 01/20/2017
|
||||||
github.com/crosbymichael/go-runc 2fdd3cd06f7443a55f6eb14ead2cac507506e718
|
github.com/crosbymichael/go-runc afca56d262e694d9056e937a0877a39ab879aeb4
|
||||||
# go-metrics client to prometheus; master as of 12/16/2016
|
# go-metrics client to prometheus; master as of 12/16/2016
|
||||||
github.com/docker/go-metrics 0f35294225552d968a13f9c5bc71a3fa44b2eb87
|
github.com/docker/go-metrics 0f35294225552d968a13f9c5bc71a3fa44b2eb87
|
||||||
# prometheus client; latest release as of 12/16/2016
|
# prometheus client; latest release as of 12/16/2016
|
||||||
|
|
5
vendor/github.com/crosbymichael/go-runc/events.go
generated
vendored
5
vendor/github.com/crosbymichael/go-runc/events.go
generated
vendored
|
@ -1,9 +1,14 @@
|
||||||
package runc
|
package runc
|
||||||
|
|
||||||
type Event struct {
|
type Event struct {
|
||||||
|
// Type are the event type generated by runc
|
||||||
|
// If the type is "error" then check the Err field on the event for
|
||||||
|
// the actual error
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Stats *Stats `json:"data,omitempty"`
|
Stats *Stats `json:"data,omitempty"`
|
||||||
|
// Err has a read error if we were unable to decode the event from runc
|
||||||
|
Err error `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Stats struct {
|
type Stats struct {
|
||||||
|
|
59
vendor/github.com/crosbymichael/go-runc/runc.go
generated
vendored
59
vendor/github.com/crosbymichael/go-runc/runc.go
generated
vendored
|
@ -13,7 +13,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Format is the type of log formatting options avaliable
|
// Format is the type of log formatting options avaliable
|
||||||
|
@ -23,14 +22,19 @@ const (
|
||||||
none Format = ""
|
none Format = ""
|
||||||
JSON Format = "json"
|
JSON Format = "json"
|
||||||
Text Format = "text"
|
Text Format = "text"
|
||||||
|
// DefaultCommand is the default command for Runc
|
||||||
|
DefaultCommand string = "runc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Runc is the client to the runc cli
|
// Runc is the client to the runc cli
|
||||||
type Runc struct {
|
type Runc struct {
|
||||||
|
//If command is empty, DefaultCommand is used
|
||||||
|
Command string
|
||||||
Root string
|
Root string
|
||||||
Debug bool
|
Debug bool
|
||||||
Log string
|
Log string
|
||||||
LogFormat Format
|
LogFormat Format
|
||||||
|
PdeathSignal syscall.Signal
|
||||||
}
|
}
|
||||||
|
|
||||||
// List returns all containers created inside the provided runc root directory
|
// List returns all containers created inside the provided runc root directory
|
||||||
|
@ -63,7 +67,7 @@ type CreateOpts struct {
|
||||||
IO
|
IO
|
||||||
// PidFile is a path to where a pid file should be created
|
// PidFile is a path to where a pid file should be created
|
||||||
PidFile string
|
PidFile string
|
||||||
Console string
|
ConsoleSocket string
|
||||||
Detach bool
|
Detach bool
|
||||||
NoPivot bool
|
NoPivot bool
|
||||||
NoNewKeyring bool
|
NoNewKeyring bool
|
||||||
|
@ -103,8 +107,8 @@ func (o *CreateOpts) args() (out []string) {
|
||||||
if o.PidFile != "" {
|
if o.PidFile != "" {
|
||||||
out = append(out, "--pid-file", o.PidFile)
|
out = append(out, "--pid-file", o.PidFile)
|
||||||
}
|
}
|
||||||
if o.Console != "" {
|
if o.ConsoleSocket != "" {
|
||||||
out = append(out, "--console", o.Console)
|
out = append(out, "--console-socket", o.ConsoleSocket)
|
||||||
}
|
}
|
||||||
if o.NoPivot {
|
if o.NoPivot {
|
||||||
out = append(out, "--no-pivot")
|
out = append(out, "--no-pivot")
|
||||||
|
@ -143,7 +147,7 @@ type ExecOpts struct {
|
||||||
Gid int
|
Gid int
|
||||||
Cwd string
|
Cwd string
|
||||||
Tty bool
|
Tty bool
|
||||||
Console string
|
ConsoleSocket string
|
||||||
Detach bool
|
Detach bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,8 +156,8 @@ func (o *ExecOpts) args() (out []string) {
|
||||||
if o.Tty {
|
if o.Tty {
|
||||||
out = append(out, "--tty")
|
out = append(out, "--tty")
|
||||||
}
|
}
|
||||||
if o.Console != "" {
|
if o.ConsoleSocket != "" {
|
||||||
out = append(out, "--console", o.Console)
|
out = append(out, "--console-socket", o.ConsoleSocket)
|
||||||
}
|
}
|
||||||
if o.Cwd != "" {
|
if o.Cwd != "" {
|
||||||
out = append(out, "--cwd", o.Cwd)
|
out = append(out, "--cwd", o.Cwd)
|
||||||
|
@ -217,9 +221,27 @@ func (r *Runc) Delete(context context.Context, id string) error {
|
||||||
return runOrError(r.command(context, "delete", id))
|
return runOrError(r.command(context, "delete", id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KillOpts specifies options for killing a container and its processes
|
||||||
|
type KillOpts struct {
|
||||||
|
All bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *KillOpts) args() (out []string) {
|
||||||
|
if o.All {
|
||||||
|
out = append(out, "--all")
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// Kill sends the specified signal to the container
|
// Kill sends the specified signal to the container
|
||||||
func (r *Runc) Kill(context context.Context, id string, sig int) error {
|
func (r *Runc) Kill(context context.Context, id string, sig int, opts *KillOpts) error {
|
||||||
return runOrError(r.command(context, "kill", id, strconv.Itoa(sig)))
|
args := []string{
|
||||||
|
"kill",
|
||||||
|
}
|
||||||
|
if opts != nil {
|
||||||
|
args = append(args, opts.args()...)
|
||||||
|
}
|
||||||
|
return runOrError(r.command(context, append(args, id, strconv.Itoa(sig))...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stats return the stats for a container like cpu, memory, and io
|
// Stats return the stats for a container like cpu, memory, and io
|
||||||
|
@ -270,8 +292,10 @@ func (r *Runc) Events(context context.Context, id string, interval time.Duration
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logrus.WithError(err).Error("runc: decode event")
|
e = Event{
|
||||||
continue
|
Type: "error",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c <- &e
|
c <- &e
|
||||||
}
|
}
|
||||||
|
@ -319,6 +343,15 @@ func (r *Runc) args() (out []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runc) command(context context.Context, args ...string) *exec.Cmd {
|
func (r *Runc) command(context context.Context, args ...string) *exec.Cmd {
|
||||||
return exec.CommandContext(context,
|
command := r.Command
|
||||||
"runc", append(r.args(), args...)...)
|
if command == "" {
|
||||||
|
command = DefaultCommand
|
||||||
|
}
|
||||||
|
cmd := exec.CommandContext(context, command, append(r.args(), args...)...)
|
||||||
|
if r.PdeathSignal != 0 {
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||||
|
Pdeathsig: r.PdeathSignal,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue