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:
Michael Crosby 2016-03-28 13:30:37 -07:00
parent 604c8d7832
commit 3742ae3ec8
6 changed files with 79 additions and 37 deletions

View file

@ -18,7 +18,7 @@ const (
)
// New returns an initialized Process supervisor.
func New(stateDir string, runtimeName string, runtimeArgs []string) (*Supervisor, error) {
func New(stateDir string, runtimeName string, runtimeArgs []string, timeout time.Duration) (*Supervisor, error) {
startTasks := make(chan *startTask, 10)
if err := os.MkdirAll(stateDir, 0755); err != nil {
return nil, err
@ -41,6 +41,7 @@ func New(stateDir string, runtimeName string, runtimeArgs []string) (*Supervisor
monitor: monitor,
runtime: runtimeName,
runtimeArgs: runtimeArgs,
timeout: timeout,
}
if err := setupEventLog(s); err != nil {
return nil, err
@ -118,6 +119,7 @@ type Supervisor struct {
tasks chan Task
monitor *Monitor
eventLog []Event
timeout time.Duration
}
// Stop closes all startTasks and sends a SIGTERM to each container's pid1 then waits for they to