go.mod: github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0
full diff: 7016d3ce23...16b287bc67
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
1432839310
commit
bd2c0898aa
2
go.mod
2
go.mod
@ -13,7 +13,7 @@ require (
|
|||||||
github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e
|
github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e
|
||||||
github.com/containerd/fifo v0.0.0-20201026212402-0724c46b320c
|
github.com/containerd/fifo v0.0.0-20201026212402-0724c46b320c
|
||||||
github.com/containerd/go-cni v1.0.1
|
github.com/containerd/go-cni v1.0.1
|
||||||
github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328
|
github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0
|
||||||
github.com/containerd/imgcrypt v1.1.1-0.20210312161619-7ed62a527887
|
github.com/containerd/imgcrypt v1.1.1-0.20210312161619-7ed62a527887
|
||||||
github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164
|
github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164
|
||||||
github.com/containerd/ttrpc v1.0.2
|
github.com/containerd/ttrpc v1.0.2
|
||||||
|
3
go.sum
3
go.sum
@ -134,8 +134,9 @@ github.com/containerd/go-cni v1.0.1 h1:VXr2EkOPD0v1gu7CKfof6XzEIDzsE/dI9yj/W7PSW
|
|||||||
github.com/containerd/go-cni v1.0.1/go.mod h1:+vUpYxKvAF72G9i1WoDOiPGRtQpqsNW/ZHtSlv++smU=
|
github.com/containerd/go-cni v1.0.1/go.mod h1:+vUpYxKvAF72G9i1WoDOiPGRtQpqsNW/ZHtSlv++smU=
|
||||||
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0=
|
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0=
|
||||||
github.com/containerd/go-runc v0.0.0-20190911050354-e029b79d8cda/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0=
|
github.com/containerd/go-runc v0.0.0-20190911050354-e029b79d8cda/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0=
|
||||||
github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328 h1:PRTagVMbJcCezLcHXe8UJvR1oBzp2lG3CEumeFOLOds=
|
|
||||||
github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328/go.mod h1:PpyHrqVs8FTi9vpyHwPwiNEGaACDxT/N/pLcvMSRA9g=
|
github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328/go.mod h1:PpyHrqVs8FTi9vpyHwPwiNEGaACDxT/N/pLcvMSRA9g=
|
||||||
|
github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0 h1:e+50zk22gvHLJKe8+d+xSMyA88PPQk/XfWuUw1BdnPA=
|
||||||
|
github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0/go.mod h1:cNU0ZbCgCQVZK4lgG3P+9tn9/PaJNmoDXPpoJhDR+Ok=
|
||||||
github.com/containerd/imgcrypt v1.0.1/go.mod h1:mdd8cEPW7TPgNG4FpuP3sGBiQ7Yi/zak9TYCG3juvb0=
|
github.com/containerd/imgcrypt v1.0.1/go.mod h1:mdd8cEPW7TPgNG4FpuP3sGBiQ7Yi/zak9TYCG3juvb0=
|
||||||
github.com/containerd/imgcrypt v1.0.4-0.20210301171431-0ae5c75f59ba/go.mod h1:6TNsg0ctmizkrOgXRNQjAPFWpMYRWuiB6dSF4Pfa5SA=
|
github.com/containerd/imgcrypt v1.0.4-0.20210301171431-0ae5c75f59ba/go.mod h1:6TNsg0ctmizkrOgXRNQjAPFWpMYRWuiB6dSF4Pfa5SA=
|
||||||
github.com/containerd/imgcrypt v1.1.1-0.20210312161619-7ed62a527887 h1:gjN37M4b3GvtvJyN6fnahr5A5fhj6PHLvzoNmdzoA74=
|
github.com/containerd/imgcrypt v1.1.1-0.20210312161619-7ed62a527887 h1:gjN37M4b3GvtvJyN6fnahr5A5fhj6PHLvzoNmdzoA74=
|
||||||
|
3
vendor/github.com/containerd/go-runc/.travis.yml
generated
vendored
3
vendor/github.com/containerd/go-runc/.travis.yml
generated
vendored
@ -1,7 +1,8 @@
|
|||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- 1.12.x
|
|
||||||
- 1.13.x
|
- 1.13.x
|
||||||
|
- 1.14.x
|
||||||
|
- 1.15.x
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- go get -t ./...
|
- go get -t ./...
|
||||||
|
9
vendor/github.com/containerd/go-runc/go.mod
generated
vendored
9
vendor/github.com/containerd/go-runc/go.mod
generated
vendored
@ -3,8 +3,9 @@ module github.com/containerd/go-runc
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e
|
github.com/containerd/console v1.0.1
|
||||||
github.com/opencontainers/runtime-spec v1.0.1
|
github.com/opencontainers/runtime-spec v1.0.2
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.9.1
|
||||||
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449
|
github.com/sirupsen/logrus v1.7.0
|
||||||
|
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f
|
||||||
)
|
)
|
||||||
|
26
vendor/github.com/containerd/go-runc/go.sum
generated
vendored
26
vendor/github.com/containerd/go-runc/go.sum
generated
vendored
@ -1,9 +1,17 @@
|
|||||||
github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e h1:GdiIYd8ZDOrT++e1NjhSD4rGt9zaJukHm4rt5F4mRQc=
|
github.com/containerd/console v1.0.1 h1:u7SFAJyRqWcG6ogaMAx3KjSTy1e3hT9QxqX7Jco7dRc=
|
||||||
github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e/go.mod h1:8Pf4gM6VEbTNRIT26AyyU7hxdQU3MvAvxVI0sc00XBE=
|
github.com/containerd/console v1.0.1/go.mod h1:XUsP6YE/mKtz6bxc+I8UiKKTP04qjQL4qcS3XoQ5xkw=
|
||||||
github.com/opencontainers/runtime-spec v1.0.1 h1:wY4pOY8fBdSIvs9+IDHC55thBuEulhzfSgKeC1yFvzQ=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 h1:gSbV7h1NRL2G1xTg/owz62CST1oJBmxy4QpMMregXVQ=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
|
||||||
|
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
|
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f h1:6Sc1XOXTulBN6imkqo6XoAXDEzoQ4/ro6xy7Vn8+rOM=
|
||||||
|
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
20
vendor/github.com/containerd/go-runc/io_unix.go
generated
vendored
20
vendor/github.com/containerd/go-runc/io_unix.go
generated
vendored
@ -20,7 +20,9 @@ package runc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewPipeIO creates pipe pairs to be used with runc
|
// NewPipeIO creates pipe pairs to be used with runc
|
||||||
@ -47,27 +49,45 @@ func NewPipeIO(uid, gid int, opts ...IOOpt) (i IO, err error) {
|
|||||||
}
|
}
|
||||||
pipes = append(pipes, stdin)
|
pipes = append(pipes, stdin)
|
||||||
if err = unix.Fchown(int(stdin.r.Fd()), uid, gid); err != nil {
|
if err = unix.Fchown(int(stdin.r.Fd()), uid, gid); err != nil {
|
||||||
|
// TODO: revert with proper darwin solution, skipping for now
|
||||||
|
// as darwin chown is returning EINVAL on anonymous pipe
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
logrus.WithError(err).Debug("failed to chown stdin, ignored")
|
||||||
|
} else {
|
||||||
return nil, errors.Wrap(err, "failed to chown stdin")
|
return nil, errors.Wrap(err, "failed to chown stdin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if option.OpenStdout {
|
if option.OpenStdout {
|
||||||
if stdout, err = newPipe(); err != nil {
|
if stdout, err = newPipe(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pipes = append(pipes, stdout)
|
pipes = append(pipes, stdout)
|
||||||
if err = unix.Fchown(int(stdout.w.Fd()), uid, gid); err != nil {
|
if err = unix.Fchown(int(stdout.w.Fd()), uid, gid); err != nil {
|
||||||
|
// TODO: revert with proper darwin solution, skipping for now
|
||||||
|
// as darwin chown is returning EINVAL on anonymous pipe
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
logrus.WithError(err).Debug("failed to chown stdout, ignored")
|
||||||
|
} else {
|
||||||
return nil, errors.Wrap(err, "failed to chown stdout")
|
return nil, errors.Wrap(err, "failed to chown stdout")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if option.OpenStderr {
|
if option.OpenStderr {
|
||||||
if stderr, err = newPipe(); err != nil {
|
if stderr, err = newPipe(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pipes = append(pipes, stderr)
|
pipes = append(pipes, stderr)
|
||||||
if err = unix.Fchown(int(stderr.w.Fd()), uid, gid); err != nil {
|
if err = unix.Fchown(int(stderr.w.Fd()), uid, gid); err != nil {
|
||||||
|
// TODO: revert with proper darwin solution, skipping for now
|
||||||
|
// as darwin chown is returning EINVAL on anonymous pipe
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
logrus.WithError(err).Debug("failed to chown stderr, ignored")
|
||||||
|
} else {
|
||||||
return nil, errors.Wrap(err, "failed to chown stderr")
|
return nil, errors.Wrap(err, "failed to chown stderr")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return &pipeIO{
|
return &pipeIO{
|
||||||
in: stdin,
|
in: stdin,
|
||||||
out: stdout,
|
out: stdout,
|
||||||
|
94
vendor/github.com/containerd/go-runc/runc.go
generated
vendored
94
vendor/github.com/containerd/go-runc/runc.go
generated
vendored
@ -29,7 +29,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
@ -55,24 +54,9 @@ const (
|
|||||||
DefaultCommand = "runc"
|
DefaultCommand = "runc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Runc is the client to the runc cli
|
|
||||||
type Runc struct {
|
|
||||||
//If command is empty, DefaultCommand is used
|
|
||||||
Command string
|
|
||||||
Root string
|
|
||||||
Debug bool
|
|
||||||
Log string
|
|
||||||
LogFormat Format
|
|
||||||
PdeathSignal syscall.Signal
|
|
||||||
Setpgid bool
|
|
||||||
Criu string
|
|
||||||
SystemdCgroup bool
|
|
||||||
Rootless *bool // nil stands for "auto"
|
|
||||||
}
|
|
||||||
|
|
||||||
// List returns all containers created inside the provided runc root directory
|
// List returns all containers created inside the provided runc root directory
|
||||||
func (r *Runc) List(context context.Context) ([]*Container, error) {
|
func (r *Runc) List(context context.Context) ([]*Container, error) {
|
||||||
data, err := cmdOutput(r.command(context, "list", "--format=json"), false)
|
data, err := cmdOutput(r.command(context, "list", "--format=json"), false, nil)
|
||||||
defer putBuf(data)
|
defer putBuf(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -86,7 +70,7 @@ func (r *Runc) List(context context.Context) ([]*Container, error) {
|
|||||||
|
|
||||||
// State returns the state for the container provided by id
|
// State returns the state for the container provided by id
|
||||||
func (r *Runc) State(context context.Context, id string) (*Container, error) {
|
func (r *Runc) State(context context.Context, id string) (*Container, error) {
|
||||||
data, err := cmdOutput(r.command(context, "state", id), true)
|
data, err := cmdOutput(r.command(context, "state", id), true, nil)
|
||||||
defer putBuf(data)
|
defer putBuf(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%s: %s", err, data.String())
|
return nil, fmt.Errorf("%s: %s", err, data.String())
|
||||||
@ -111,6 +95,7 @@ type CreateOpts struct {
|
|||||||
NoPivot bool
|
NoPivot bool
|
||||||
NoNewKeyring bool
|
NoNewKeyring bool
|
||||||
ExtraFiles []*os.File
|
ExtraFiles []*os.File
|
||||||
|
Started chan<- int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *CreateOpts) args() (out []string, err error) {
|
func (o *CreateOpts) args() (out []string, err error) {
|
||||||
@ -156,7 +141,7 @@ func (r *Runc) Create(context context.Context, id, bundle string, opts *CreateOp
|
|||||||
cmd.ExtraFiles = opts.ExtraFiles
|
cmd.ExtraFiles = opts.ExtraFiles
|
||||||
|
|
||||||
if cmd.Stdout == nil && cmd.Stderr == nil {
|
if cmd.Stdout == nil && cmd.Stderr == nil {
|
||||||
data, err := cmdOutput(cmd, true)
|
data, err := cmdOutput(cmd, true, nil)
|
||||||
defer putBuf(data)
|
defer putBuf(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %s", err, data.String())
|
return fmt.Errorf("%s: %s", err, data.String())
|
||||||
@ -176,7 +161,7 @@ func (r *Runc) Create(context context.Context, id, bundle string, opts *CreateOp
|
|||||||
}
|
}
|
||||||
status, err := Monitor.Wait(cmd, ec)
|
status, err := Monitor.Wait(cmd, ec)
|
||||||
if err == nil && status != 0 {
|
if err == nil && status != 0 {
|
||||||
err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
|
err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -191,6 +176,7 @@ type ExecOpts struct {
|
|||||||
PidFile string
|
PidFile string
|
||||||
ConsoleSocket ConsoleSocket
|
ConsoleSocket ConsoleSocket
|
||||||
Detach bool
|
Detach bool
|
||||||
|
Started chan<- int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ExecOpts) args() (out []string, err error) {
|
func (o *ExecOpts) args() (out []string, err error) {
|
||||||
@ -210,9 +196,12 @@ func (o *ExecOpts) args() (out []string, err error) {
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec executres and additional process inside the container based on a full
|
// Exec executes an additional process inside the container based on a full
|
||||||
// OCI Process specification
|
// OCI Process specification
|
||||||
func (r *Runc) Exec(context context.Context, id string, spec specs.Process, opts *ExecOpts) error {
|
func (r *Runc) Exec(context context.Context, id string, spec specs.Process, opts *ExecOpts) error {
|
||||||
|
if opts.Started != nil {
|
||||||
|
defer close(opts.Started)
|
||||||
|
}
|
||||||
f, err := ioutil.TempFile(os.Getenv("XDG_RUNTIME_DIR"), "runc-process")
|
f, err := ioutil.TempFile(os.Getenv("XDG_RUNTIME_DIR"), "runc-process")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -236,10 +225,10 @@ func (r *Runc) Exec(context context.Context, id string, spec specs.Process, opts
|
|||||||
opts.Set(cmd)
|
opts.Set(cmd)
|
||||||
}
|
}
|
||||||
if cmd.Stdout == nil && cmd.Stderr == nil {
|
if cmd.Stdout == nil && cmd.Stderr == nil {
|
||||||
data, err := cmdOutput(cmd, true)
|
data, err := cmdOutput(cmd, true, opts.Started)
|
||||||
defer putBuf(data)
|
defer putBuf(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %s", err, data.String())
|
return fmt.Errorf("%w: %s", err, data.String())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -247,6 +236,9 @@ func (r *Runc) Exec(context context.Context, id string, spec specs.Process, opts
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if opts.Started != nil {
|
||||||
|
opts.Started <- cmd.Process.Pid
|
||||||
|
}
|
||||||
if opts != nil && opts.IO != nil {
|
if opts != nil && opts.IO != nil {
|
||||||
if c, ok := opts.IO.(StartCloser); ok {
|
if c, ok := opts.IO.(StartCloser); ok {
|
||||||
if err := c.CloseAfterStart(); err != nil {
|
if err := c.CloseAfterStart(); err != nil {
|
||||||
@ -256,7 +248,7 @@ func (r *Runc) Exec(context context.Context, id string, spec specs.Process, opts
|
|||||||
}
|
}
|
||||||
status, err := Monitor.Wait(cmd, ec)
|
status, err := Monitor.Wait(cmd, ec)
|
||||||
if err == nil && status != 0 {
|
if err == nil && status != 0 {
|
||||||
err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
|
err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -264,6 +256,9 @@ func (r *Runc) Exec(context context.Context, id string, spec specs.Process, opts
|
|||||||
// Run runs the create, start, delete lifecycle of the container
|
// Run runs the create, start, delete lifecycle of the container
|
||||||
// and returns its exit status after it has exited
|
// and returns its exit status after it has exited
|
||||||
func (r *Runc) Run(context context.Context, id, bundle string, opts *CreateOpts) (int, error) {
|
func (r *Runc) Run(context context.Context, id, bundle string, opts *CreateOpts) (int, error) {
|
||||||
|
if opts.Started != nil {
|
||||||
|
defer close(opts.Started)
|
||||||
|
}
|
||||||
args := []string{"run", "--bundle", bundle}
|
args := []string{"run", "--bundle", bundle}
|
||||||
if opts != nil {
|
if opts != nil {
|
||||||
oargs, err := opts.args()
|
oargs, err := opts.args()
|
||||||
@ -280,9 +275,12 @@ func (r *Runc) Run(context context.Context, id, bundle string, opts *CreateOpts)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
if opts.Started != nil {
|
||||||
|
opts.Started <- cmd.Process.Pid
|
||||||
|
}
|
||||||
status, err := Monitor.Wait(cmd, ec)
|
status, err := Monitor.Wait(cmd, ec)
|
||||||
if err == nil && status != 0 {
|
if err == nil && status != 0 {
|
||||||
err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
|
err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
|
||||||
}
|
}
|
||||||
return status, err
|
return status, err
|
||||||
}
|
}
|
||||||
@ -403,7 +401,7 @@ func (r *Runc) Resume(context context.Context, id string) error {
|
|||||||
|
|
||||||
// Ps lists all the processes inside the container returning their pids
|
// Ps lists all the processes inside the container returning their pids
|
||||||
func (r *Runc) Ps(context context.Context, id string) ([]int, error) {
|
func (r *Runc) Ps(context context.Context, id string) ([]int, error) {
|
||||||
data, err := cmdOutput(r.command(context, "ps", "--format", "json", id), true)
|
data, err := cmdOutput(r.command(context, "ps", "--format", "json", id), true, nil)
|
||||||
defer putBuf(data)
|
defer putBuf(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%s: %s", err, data.String())
|
return nil, fmt.Errorf("%s: %s", err, data.String())
|
||||||
@ -417,7 +415,7 @@ func (r *Runc) Ps(context context.Context, id string) ([]int, error) {
|
|||||||
|
|
||||||
// Top lists all the processes inside the container returning the full ps data
|
// Top lists all the processes inside the container returning the full ps data
|
||||||
func (r *Runc) Top(context context.Context, id string, psOptions string) (*TopResults, error) {
|
func (r *Runc) Top(context context.Context, id string, psOptions string) (*TopResults, error) {
|
||||||
data, err := cmdOutput(r.command(context, "ps", "--format", "table", id, psOptions), true)
|
data, err := cmdOutput(r.command(context, "ps", "--format", "table", id, psOptions), true, nil)
|
||||||
defer putBuf(data)
|
defer putBuf(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%s: %s", err, data.String())
|
return nil, fmt.Errorf("%s: %s", err, data.String())
|
||||||
@ -452,6 +450,10 @@ type CheckpointOpts struct {
|
|||||||
// EmptyNamespaces creates a namespace for the container but does not save its properties
|
// EmptyNamespaces creates a namespace for the container but does not save its properties
|
||||||
// Provide the namespaces you wish to be checkpointed without their settings on restore
|
// Provide the namespaces you wish to be checkpointed without their settings on restore
|
||||||
EmptyNamespaces []string
|
EmptyNamespaces []string
|
||||||
|
// LazyPages uses userfaultfd to lazily restore memory pages
|
||||||
|
LazyPages bool
|
||||||
|
// StatusFile is the file criu writes \0 to once lazy-pages is ready
|
||||||
|
StatusFile *os.File
|
||||||
}
|
}
|
||||||
|
|
||||||
type CgroupMode string
|
type CgroupMode string
|
||||||
@ -493,6 +495,9 @@ func (o *CheckpointOpts) args() (out []string) {
|
|||||||
for _, ns := range o.EmptyNamespaces {
|
for _, ns := range o.EmptyNamespaces {
|
||||||
out = append(out, "--empty-ns", ns)
|
out = append(out, "--empty-ns", ns)
|
||||||
}
|
}
|
||||||
|
if o.LazyPages {
|
||||||
|
out = append(out, "--lazy-pages")
|
||||||
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,13 +516,23 @@ func PreDump(args []string) []string {
|
|||||||
// Checkpoint allows you to checkpoint a container using criu
|
// Checkpoint allows you to checkpoint a container using criu
|
||||||
func (r *Runc) Checkpoint(context context.Context, id string, opts *CheckpointOpts, actions ...CheckpointAction) error {
|
func (r *Runc) Checkpoint(context context.Context, id string, opts *CheckpointOpts, actions ...CheckpointAction) error {
|
||||||
args := []string{"checkpoint"}
|
args := []string{"checkpoint"}
|
||||||
|
extraFiles := []*os.File{}
|
||||||
if opts != nil {
|
if opts != nil {
|
||||||
args = append(args, opts.args()...)
|
args = append(args, opts.args()...)
|
||||||
|
if opts.StatusFile != nil {
|
||||||
|
// pass the status file to the child process
|
||||||
|
extraFiles = []*os.File{opts.StatusFile}
|
||||||
|
// set status-fd to 3 as this will be the file descriptor
|
||||||
|
// of the first file passed with cmd.ExtraFiles
|
||||||
|
args = append(args, "--status-fd", "3")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for _, a := range actions {
|
for _, a := range actions {
|
||||||
args = a(args)
|
args = a(args)
|
||||||
}
|
}
|
||||||
return r.runOrError(r.command(context, append(args, id)...))
|
cmd := r.command(context, append(args, id)...)
|
||||||
|
cmd.ExtraFiles = extraFiles
|
||||||
|
return r.runOrError(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
type RestoreOpts struct {
|
type RestoreOpts struct {
|
||||||
@ -583,7 +598,7 @@ func (r *Runc) Restore(context context.Context, id, bundle string, opts *Restore
|
|||||||
}
|
}
|
||||||
status, err := Monitor.Wait(cmd, ec)
|
status, err := Monitor.Wait(cmd, ec)
|
||||||
if err == nil && status != 0 {
|
if err == nil && status != 0 {
|
||||||
err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
|
err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
|
||||||
}
|
}
|
||||||
return status, err
|
return status, err
|
||||||
}
|
}
|
||||||
@ -612,7 +627,7 @@ type Version struct {
|
|||||||
|
|
||||||
// Version returns the runc and runtime-spec versions
|
// Version returns the runc and runtime-spec versions
|
||||||
func (r *Runc) Version(context context.Context) (Version, error) {
|
func (r *Runc) Version(context context.Context) (Version, error) {
|
||||||
data, err := cmdOutput(r.command(context, "--version"), false)
|
data, err := cmdOutput(r.command(context, "--version"), false, nil)
|
||||||
defer putBuf(data)
|
defer putBuf(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Version{}, err
|
return Version{}, err
|
||||||
@ -680,11 +695,11 @@ func (r *Runc) runOrError(cmd *exec.Cmd) error {
|
|||||||
}
|
}
|
||||||
status, err := Monitor.Wait(cmd, ec)
|
status, err := Monitor.Wait(cmd, ec)
|
||||||
if err == nil && status != 0 {
|
if err == nil && status != 0 {
|
||||||
err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
|
err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
data, err := cmdOutput(cmd, true)
|
data, err := cmdOutput(cmd, true, nil)
|
||||||
defer putBuf(data)
|
defer putBuf(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %s", err, data.String())
|
return fmt.Errorf("%s: %s", err, data.String())
|
||||||
@ -694,7 +709,7 @@ func (r *Runc) runOrError(cmd *exec.Cmd) error {
|
|||||||
|
|
||||||
// callers of cmdOutput are expected to call putBuf on the returned Buffer
|
// callers of cmdOutput are expected to call putBuf on the returned Buffer
|
||||||
// to ensure it is released back to the shared pool after use.
|
// to ensure it is released back to the shared pool after use.
|
||||||
func cmdOutput(cmd *exec.Cmd, combined bool) (*bytes.Buffer, error) {
|
func cmdOutput(cmd *exec.Cmd, combined bool, started chan<- int) (*bytes.Buffer, error) {
|
||||||
b := getBuf()
|
b := getBuf()
|
||||||
|
|
||||||
cmd.Stdout = b
|
cmd.Stdout = b
|
||||||
@ -705,11 +720,22 @@ func cmdOutput(cmd *exec.Cmd, combined bool) (*bytes.Buffer, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if started != nil {
|
||||||
|
started <- cmd.Process.Pid
|
||||||
|
}
|
||||||
|
|
||||||
status, err := Monitor.Wait(cmd, ec)
|
status, err := Monitor.Wait(cmd, ec)
|
||||||
if err == nil && status != 0 {
|
if err == nil && status != 0 {
|
||||||
err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
|
err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
|
||||||
}
|
}
|
||||||
|
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ExitError struct {
|
||||||
|
Status int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ExitError) Error() string {
|
||||||
|
return fmt.Sprintf("exit status %d", e.Status)
|
||||||
|
}
|
||||||
|
38
vendor/github.com/containerd/go-runc/runc_unix.go
generated
vendored
Normal file
38
vendor/github.com/containerd/go-runc/runc_unix.go
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
//+build !windows
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright The containerd Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package runc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Runc is the client to the runc cli
|
||||||
|
type Runc struct {
|
||||||
|
//If command is empty, DefaultCommand is used
|
||||||
|
Command string
|
||||||
|
Root string
|
||||||
|
Debug bool
|
||||||
|
Log string
|
||||||
|
LogFormat Format
|
||||||
|
PdeathSignal unix.Signal
|
||||||
|
Setpgid bool
|
||||||
|
Criu string
|
||||||
|
SystemdCgroup bool
|
||||||
|
Rootless *bool // nil stands for "auto"
|
||||||
|
}
|
31
vendor/github.com/containerd/go-runc/runc_windows.go
generated
vendored
Normal file
31
vendor/github.com/containerd/go-runc/runc_windows.go
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
Copyright The containerd Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package runc
|
||||||
|
|
||||||
|
// Runc is the client to the runc cli
|
||||||
|
type Runc struct {
|
||||||
|
//If command is empty, DefaultCommand is used
|
||||||
|
Command string
|
||||||
|
Root string
|
||||||
|
Debug bool
|
||||||
|
Log string
|
||||||
|
LogFormat Format
|
||||||
|
Setpgid bool
|
||||||
|
Criu string
|
||||||
|
SystemdCgroup bool
|
||||||
|
Rootless *bool // nil stands for "auto"
|
||||||
|
}
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -87,7 +87,7 @@ github.com/containerd/fifo
|
|||||||
# github.com/containerd/go-cni v1.0.1
|
# github.com/containerd/go-cni v1.0.1
|
||||||
## explicit
|
## explicit
|
||||||
github.com/containerd/go-cni
|
github.com/containerd/go-cni
|
||||||
# github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328
|
# github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0
|
||||||
## explicit
|
## explicit
|
||||||
github.com/containerd/go-runc
|
github.com/containerd/go-runc
|
||||||
# github.com/containerd/imgcrypt v1.1.1-0.20210312161619-7ed62a527887
|
# github.com/containerd/imgcrypt v1.1.1-0.20210312161619-7ed62a527887
|
||||||
|
Loading…
Reference in New Issue
Block a user