Merge pull request #320 from dani-docker/18.09-bk-3945401
[18.09 backport] do not stop health check before sending signal
diff --git a/daemon/kill.go b/daemon/kill.go
index 3e6457e..f3ac070 100644
--- a/daemon/kill.go
+++ b/daemon/kill.go
@@ -64,8 +64,6 @@
container.Lock()
defer container.Unlock()
- daemon.stopHealthchecks(container)
-
if !container.Running {
return errNotRunning(container.ID)
}
diff --git a/integration/container/health_test.go b/integration/container/health_test.go
index f4117f5..64284c8 100644
--- a/integration/container/health_test.go
+++ b/integration/container/health_test.go
@@ -9,6 +9,7 @@
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/docker/docker/integration/internal/container"
+ "gotest.tools/assert"
"gotest.tools/poll"
"gotest.tools/skip"
)
@@ -32,6 +33,35 @@
poll.WaitOn(t, pollForHealthStatus(ctx, client, cID, types.Healthy), poll.WithDelay(100*time.Millisecond))
}
+// GitHub #37263
+// Do not stop healthchecks just because we sent a signal to the container
+func TestHealthKillContainer(t *testing.T) {
+ skip.If(t, testEnv.OSType == "windows", "Windows only supports SIGKILL and SIGTERM? See https://github.com/moby/moby/issues/39574")
+ defer setupTest(t)()
+
+ ctx := context.Background()
+ client := testEnv.APIClient()
+
+ id := container.Run(t, ctx, client, func(c *container.TestContainerConfig) {
+ c.Config.Healthcheck = &containertypes.HealthConfig{
+ Test: []string{"CMD-SHELL", "sleep 1"},
+ Interval: time.Second,
+ Retries: 5,
+ }
+ })
+
+ ctxPoll, cancel := context.WithTimeout(ctx, 30*time.Second)
+ defer cancel()
+ poll.WaitOn(t, pollForHealthStatus(ctxPoll, client, id, "healthy"), poll.WithDelay(100*time.Millisecond))
+
+ err := client.ContainerKill(ctx, id, "SIGUSR1")
+ assert.NilError(t, err)
+
+ ctxPoll, cancel = context.WithTimeout(ctx, 30*time.Second)
+ defer cancel()
+ poll.WaitOn(t, pollForHealthStatus(ctxPoll, client, id, "healthy"), poll.WithDelay(100*time.Millisecond))
+}
+
func pollForHealthStatus(ctx context.Context, client client.APIClient, containerID string, healthStatus string) func(log poll.LogT) poll.Result {
return func(log poll.LogT) poll.Result {
inspect, err := client.ContainerInspect(ctx, containerID)