1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

do not stop health check before sending signal

Docker daemon always stops healthcheck before sending signal to a
container now. However, when we use "docker kill" to send signals
other than SIGTERM or SIGKILL to a container, such as SIGINT,
daemon still stops container health check though container process
handles the signal normally and continues to work.

Signed-off-by: Ruilin Li <liruilin4@huawei.com>
(cherry picked from commit da574f9343)
Signed-off-by: Dani Louca <dani.louca@docker.com>
This commit is contained in:
Ruilin Li 2018-06-11 17:59:26 +08:00 committed by Dani Louca
parent 4bed01298c
commit 32802bc7d9
2 changed files with 26 additions and 2 deletions

View file

@ -64,8 +64,6 @@ func (daemon *Daemon) killWithSignal(container *containerpkg.Container, sig int)
container.Lock()
defer container.Unlock()
daemon.stopHealthchecks(container)
if !container.Running {
return errNotRunning(container.ID)
}

View file

@ -165,3 +165,29 @@ ENTRYPOINT /bin/sh -c "sleep 600"`))
waitForHealthStatus(c, name, "starting", "healthy")
}
// GitHub #37263
func (s *DockerSuite) TestHealthKillContainer(c *check.C) {
testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows
imageName := "testhealth"
buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox
HEALTHCHECK --interval=1s --timeout=5s --retries=5 CMD /bin/sh -c "sleep 1"
ENTRYPOINT /bin/sh -c "sleep 600"`))
name := "test_health_kill"
dockerCmd(c, "run", "-d", "--name", name, imageName)
defer func() {
dockerCmd(c, "rm", "-f", name)
dockerCmd(c, "rmi", imageName)
}()
// Start
dockerCmd(c, "start", name)
waitForHealthStatus(c, name, "starting", "healthy")
dockerCmd(c, "kill", "-s", "SIGINT", name)
out, _ := dockerCmd(c, "inspect", "--format={{.State.Health.Status}}", name)
c.Check(out, checker.Equals, "healthy\n")
}