docker:do not stop health check before sending signal

This commit is contained in:
zhongjiawei 2022-12-01 15:19:28 +08:00
parent 2ff1c05189
commit 365eb0b196
5 changed files with 70 additions and 3 deletions

View File

@ -1 +1 @@
18.09.0.315
18.09.0.316

View File

@ -1,6 +1,6 @@
Name: docker-engine
Version: 18.09.0
Release: 315
Release: 316
Epoch: 2
Summary: The open-source application container engine
Group: Tools/Docker
@ -213,6 +213,12 @@ fi
%endif
%changelog
* Thu Dec 01 2022 zhongjiawei<zhongjiawei1@huawei.com> - 18.09.0-316
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:do not stop health check before sending signal
* Thu Nov 24 2022 chenjiankun<chenjiankun1@huawei.com> - 18.09.0-315
- Type:bugfix
- CVE:NA

View File

@ -1 +1 @@
c8f038afd97f57b150946e88df14762a5d4dfc98
9b9af2f4670efbadf39b4fce731a677ad70ebb07

View File

@ -0,0 +1,60 @@
From b1151e821dd3510b88c67db5694f06fa6c772767 Mon Sep 17 00:00:00 2001
From: zhongjiawei <zhongjiawei1@huawei.com>
Date: Thu, 1 Dec 2022 15:09:28 +0800
Subject: [PATCH] docker:do not stop health check before sending signal
---
components/engine/daemon/kill.go | 2 --
.../integration-cli/docker_cli_health_test.go | 26 +++++++++++++++++++
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/components/engine/daemon/kill.go b/components/engine/daemon/kill.go
index cb0ec61d..13079a60 100644
--- a/components/engine/daemon/kill.go
+++ b/components/engine/daemon/kill.go
@@ -64,8 +64,6 @@ func (daemon *Daemon) killWithSignal(container *containerpkg.Container, sig int)
container.Lock()
defer container.Unlock()
- daemon.stopHealthchecks(container)
-
// We could unpause the container for them rather than returning this error
if container.Paused {
return fmt.Errorf("Container %s is paused. Unpause the container before stopping or killing", container.ID)
diff --git a/components/engine/integration-cli/docker_cli_health_test.go b/components/engine/integration-cli/docker_cli_health_test.go
index 4fb63994..2b5b3672 100644
--- a/components/engine/integration-cli/docker_cli_health_test.go
+++ b/components/engine/integration-cli/docker_cli_health_test.go
@@ -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")
+
+}
--
2.30.0

View File

@ -232,4 +232,5 @@ patch/0231-docker-AdditionalGids-must-include-effective-group-I.patch
patch/0232-docker-ensure-layer-digest-folder-removed-if-ls.driv.patch
patch/0233-docker-cleanup-netns-file-when-close-docker-daemon.patch
patch/0234-docker-Read-connection-marking-information-from-CT-f.patch
patch/0235-docker-do-not-stop-health-check-before-sending-signa.patch
#end