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:
parent
4bed01298c
commit
32802bc7d9
2 changed files with 26 additions and 2 deletions
|
@ -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")
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue