Add proper handling for SIGKILL'ed shim

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2016-09-01 11:29:24 -07:00
parent dd71165fc6
commit fe5f3d5581
4 changed files with 104 additions and 1 deletions

View file

@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"syscall"
"time"
@ -488,3 +489,50 @@ func swapEnabled() bool {
_, err := os.Stat("/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes")
return err == nil
}
func (cs *ContainerdSuite) TestSigkillShimReuseName(t *check.C) {
bundleName := "busybox-top"
if err := CreateBusyboxBundle(bundleName, []string{"top"}); err != nil {
t.Fatal(err)
}
containerID := "top"
c, err := cs.StartContainer(containerID, bundleName)
if err != nil {
t.Fatal(err)
}
// Sigkill the shim
exec.Command("pkill", "-9", "containerd-shim").Run()
// Wait for it to be reaped
for _, evt := range []types.Event{
{
Type: "start-container",
Id: containerID,
Status: 0,
Pid: "",
},
{
Type: "exit",
Id: containerID,
Status: 128 + 9,
Pid: "init",
},
} {
ch := c.GetEventsChannel()
select {
case e := <-ch:
evt.Timestamp = e.Timestamp
t.Assert(*e, checker.Equals, evt)
case <-time.After(2 * time.Second):
t.Fatal("Container took more than 2 seconds to terminate")
}
}
// Start a new continer with the same name
c, err = cs.StartContainer(containerID, bundleName)
if err != nil {
t.Fatal(err)
}
}