From c0d5f8afd599a93a1b27b6d4f5c1abf941e8da02 Mon Sep 17 00:00:00 2001 From: liuzekun Date: Fri, 10 Apr 2020 17:08:21 +0800 Subject: [PATCH] docker: check whether exit file is exist before kill process directly kill process directly should check whether exit file is exist already, for avoid kill the new process which reused this pid Signed-off-by: liuzekun --- VERSION-openeuler | 2 +- docker-engine-openeuler.spec | 2 +- ...ess-exit-file-when-kill-process-dire.patch | 36 +++++++++++++++++++ series.conf | 1 + 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 patch/0163-docker-stat-process-exit-file-when-kill-process-dire.patch diff --git a/VERSION-openeuler b/VERSION-openeuler index fa1cead..7c351c9 100644 --- a/VERSION-openeuler +++ b/VERSION-openeuler @@ -1 +1 @@ -18.09.0.103 +18.09.0.104 diff --git a/docker-engine-openeuler.spec b/docker-engine-openeuler.spec index 9098317..5a700de 100644 --- a/docker-engine-openeuler.spec +++ b/docker-engine-openeuler.spec @@ -1,6 +1,6 @@ Name: docker-engine Version: 18.09.0 -Release: 103 +Release: 104 Summary: The open-source application container engine Group: Tools/Docker diff --git a/patch/0163-docker-stat-process-exit-file-when-kill-process-dire.patch b/patch/0163-docker-stat-process-exit-file-when-kill-process-dire.patch new file mode 100644 index 0000000..4fbb7de --- /dev/null +++ b/patch/0163-docker-stat-process-exit-file-when-kill-process-dire.patch @@ -0,0 +1,36 @@ +From 3f285224ade14c9d64dfc81cf9b5d969343a641e Mon Sep 17 00:00:00 2001 +From: liuzekun +Date: Wed, 8 Apr 2020 19:49:38 +0800 +Subject: [PATCH] docker: stat process exit file when kill process directly + +reason: stat process exit file when kill process directly + +Signed-off-by: liuzekun +--- + components/engine/daemon/container_operations_unix.go | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/components/engine/daemon/container_operations_unix.go b/components/engine/daemon/container_operations_unix.go +index 2cc2b2e3..df2f3261 100644 +--- a/components/engine/daemon/container_operations_unix.go ++++ b/components/engine/daemon/container_operations_unix.go +@@ -346,6 +346,16 @@ func killProcessDirectly(cntr *container.Container) error { + // Ensure that we don't kill ourselves + if pid := cntr.GetPID(); pid != 0 { + logrus.Infof("Container %s failed to exit within 10 seconds of kill - trying direct SIGKILL", stringid.TruncateID(cntr.ID)) ++ pattern := fmt.Sprintf("/var/run/docker/containerd/exit/moby/%s.%d.*", cntr.ID, pid) ++ efiles, err := filepath.Glob(pattern) ++ if err != nil { ++ logrus.Warnf("Match exit file with pattern %q failed: %s", pattern, err.Error()) ++ } ++ if len(efiles) != 0 { ++ logrus.Infof("Find process exit files with pattern %q: %+v, skip force kill because the process is exit already", pattern, efiles) ++ return errNoSuchProcess{pid, 9} ++ } ++ + if err := unix.Kill(pid, 9); err != nil { + if err != unix.ESRCH { + return err +-- +2.19.1 + diff --git a/series.conf b/series.conf index d8ce86d..4fe3e7e 100644 --- a/series.conf +++ b/series.conf @@ -158,3 +158,4 @@ patch/0159-docker-extend-timeout-in-cli-testcases.patch patch/0160-docker-create-a-soft-link-from-runtime-default-to-ru.patch patch/0161-docker-Delete-stale-containerd-object-on-start-f.patch patch/0162-docker-delete-event-is-not-need-to-process.patch +patch/0163-docker-stat-process-exit-file-when-kill-process-dire.patch