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 da574f93432e600fda561da5e6983e7f69b364a9)
Signed-off-by: Dani Louca <dani.louca@docker.com>
Upstream-commit: afee55c3740644be40882d883d8287782f2bc6c2
Component: engine
This commit is contained in:
Ruilin Li
2019-08-14 16:44:11 -04:00
committed by Dani Louca
parent d0f7c1a7ee
commit a5049e1961
2 changed files with 26 additions and 2 deletions
-2
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)
}
@@ -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")
}