Add timeout flag for container start times
This currently depends on a runc PR: https://github.com/opencontainers/runc/pull/703 We need this pr because we have to SIGKILL runc and the container root dir will still be left around. As for the containerd changes this adds a flag to containerd so that you can configure the timeout without any more code changes. It also adds better handling in the error cases and will kill the containerd-shim and runc ( as well as the user process if it exists ) if the timeout is hit. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
604c8d7832
commit
3742ae3ec8
6 changed files with 79 additions and 37 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/containerd/specs"
|
||||
|
@ -90,6 +91,7 @@ type ContainerOpts struct {
|
|||
RuntimeArgs []string
|
||||
Labels []string
|
||||
NoPivotRoot bool
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
// New returns a new container
|
||||
|
@ -103,6 +105,7 @@ func New(opts ContainerOpts) (Container, error) {
|
|||
runtime: opts.Runtime,
|
||||
runtimeArgs: opts.RuntimeArgs,
|
||||
noPivotRoot: opts.NoPivotRoot,
|
||||
timeout: opts.Timeout,
|
||||
}
|
||||
if err := os.Mkdir(filepath.Join(c.root, c.id), 0755); err != nil {
|
||||
return nil, err
|
||||
|
@ -191,6 +194,7 @@ type container struct {
|
|||
labels []string
|
||||
oomFds []int
|
||||
noPivotRoot bool
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func (c *container) ID() string {
|
||||
|
@ -223,8 +227,9 @@ func (c *container) Delete() error {
|
|||
|
||||
args := c.runtimeArgs
|
||||
args = append(args, "delete", c.id)
|
||||
exec.Command(c.runtime, args...).Run()
|
||||
|
||||
if derr := exec.Command(c.runtime, args...).Run(); err == nil {
|
||||
err = derr
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue