mirror of
https://github.com/docker/cli.git
synced 2026-09-28 02:06:53 -04: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 da574f93432e600fda561da5e6983e7f69b364a9) Signed-off-by: Dani Louca <dani.louca@docker.com> Upstream-commit: afee55c3740644be40882d883d8287782f2bc6c2 Component: engine
This commit is contained in:
@@ -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")
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user