Remove container on load if it exited
If the shim gets sigkilled while containerd is down we need to be able to remove the container correctly so that it does not stay in a stopped state forever. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -38,14 +38,10 @@ func getRootIDs(s *specs.PlatformSpec) (int, int, error) {
|
||||
|
||||
func (c *container) State() State {
|
||||
proc := c.processes["init"]
|
||||
if proc == nil || proc.pid == 0 {
|
||||
if proc == nil {
|
||||
return Stopped
|
||||
}
|
||||
err := syscall.Kill(proc.pid, 0)
|
||||
if err != nil && err == syscall.ESRCH {
|
||||
return Stopped
|
||||
}
|
||||
return Running
|
||||
return proc.State()
|
||||
}
|
||||
|
||||
func (c *container) Runtime() string {
|
||||
@@ -53,11 +49,11 @@ func (c *container) Runtime() string {
|
||||
}
|
||||
|
||||
func (c *container) Pause() error {
|
||||
return exec.Command("runc", "pause", c.id).Run()
|
||||
return exec.Command(c.runtime, "pause", c.id).Run()
|
||||
}
|
||||
|
||||
func (c *container) Resume() error {
|
||||
return exec.Command("runc", "resume", c.id).Run()
|
||||
return exec.Command(c.runtime, "resume", c.id).Run()
|
||||
}
|
||||
|
||||
func (c *container) Checkpoints() ([]Checkpoint, error) {
|
||||
@@ -336,6 +332,7 @@ func waitForStart(p *process, cmd *exec.Cmd) error {
|
||||
return errNoPidFile
|
||||
}
|
||||
|
||||
// isAlive checks if the shim that launched the container is still alive
|
||||
func isAlive(cmd *exec.Cmd) (bool, error) {
|
||||
if err := syscall.Kill(cmd.Process.Pid, 0); err != nil {
|
||||
if err == syscall.ESRCH {
|
||||
|
Reference in New Issue
Block a user