Merge pull request #4950 from hashicorp/b-exc-libcontainer-kill

executor: kill all container processes
This commit is contained in:
Mahmood Ali
2018-12-08 09:52:42 -05:00
committed by GitHub
3 changed files with 111 additions and 53 deletions

View File

@@ -247,7 +247,7 @@ func (l *LibcontainerExecutor) wait() {
ps = exitErr.ProcessState
} else {
l.logger.Error("failed to call wait on user process", "error", err)
l.exitState = &ProcessState{Pid: 0, ExitCode: 0, Time: time.Now()}
l.exitState = &ProcessState{Pid: 0, ExitCode: 1, Time: time.Now()}
return
}
}
@@ -310,6 +310,8 @@ func (l *LibcontainerExecutor) Shutdown(signal string, grace time.Duration) erro
return fmt.Errorf("error unknown signal given for shutdown: %s", signal)
}
// Signal initial container processes only during graceful
// shutdown; hence `false` arg.
err = l.container.Signal(sig, false)
if err != nil {
return err
@@ -319,10 +321,12 @@ func (l *LibcontainerExecutor) Shutdown(signal string, grace time.Duration) erro
case <-l.userProcExited:
return nil
case <-time.After(grace):
return l.container.Signal(os.Kill, false)
// Force kill all container processes after grace period,
// hence `true` argument.
return l.container.Signal(os.Kill, true)
}
} else {
return l.container.Signal(os.Kill, false)
return l.container.Signal(os.Kill, true)
}
}