Merge pull request #321 from dani-docker/19.03-bk-3945401
[19.03 backport] do not stop health check before sending signal
This commit is contained in:
commit
cddce2dfa7
2 changed files with 30 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)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
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 @@ func TestHealthCheckWorkdir(t *testing.T) {
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue