!119 [sync] PR-118: [sync] docker: Add an ExitPid field for State struct to record exit process id

From: @openeuler-sync-bot 
Reviewed-by: @duguhaotian 
Signed-off-by: @duguhaotian
This commit is contained in:
openeuler-ci-bot 2022-09-15 08:27:08 +00:00 committed by Gitee
commit 2f0e2c80ed
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 57 additions and 2 deletions

View File

@ -1 +1 @@
18.09.0.239
18.09.0.240

View File

@ -1,6 +1,6 @@
Name: docker-engine
Version: 18.09.0
Release: 239
Release: 240
Summary: The open-source application container engine
Group: Tools/Docker
@ -198,6 +198,12 @@ fi
%endif
%changelog
* Thu Sep 15 2022 chenjiankun <chenjiankun1@huawei.com> - 18.09.0-240
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:Add an ExitPid field for State struct to record exit process id
* Thu Sep 15 2022 chenjiankun <chenjiankun1@huawei.com> - 18.09.0-239
- Type:bugfix
- CVE:NA

View File

@ -0,0 +1,48 @@
From ebe1a56fb28e7de7128167973a99061e6aa0222a Mon Sep 17 00:00:00 2001
From: chenjiankun <chenjiankun1@huawei.com>
Date: Thu, 7 Jul 2022 10:18:03 +0800
Subject: [PATCH] docker: Add an ExitPid field for State struct to record exit
process id
---
components/engine/container/state.go | 1 +
components/engine/daemon/monitor.go | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/components/engine/container/state.go b/components/engine/container/state.go
index da19cc49e..292b0ec0b 100644
--- a/components/engine/container/state.go
+++ b/components/engine/container/state.go
@@ -27,6 +27,7 @@ type State struct {
RemovalInProgress bool // Not need for this to be persistent on disk.
Dead bool
Pid int
+ ExitPid uint32 // record exit process id.
ExitCodeValue int `json:"ExitCode"`
ErrorMsg string `json:"Error"` // contains last known error during container start, stop, or remove
StartedAt time.Time
diff --git a/components/engine/daemon/monitor.go b/components/engine/daemon/monitor.go
index a5c7ff5c8..89c05f3da 100644
--- a/components/engine/daemon/monitor.go
+++ b/components/engine/daemon/monitor.go
@@ -57,6 +57,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerd.EventType, ei libc
daemon.LogContainerEvent(c, "oom")
case libcontainerd.EventExit:
+ c.ExitPid = ei.Pid
if int(ei.Pid) == c.Pid {
logrus.Infof("handle container %s exit event pid=%d", c.ID, c.Pid)
c.Lock()
@@ -169,6 +170,9 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerd.EventType, ei libc
// This is here to handle start not generated by docker
if !c.Running {
+ if c.ExitPid == ei.Pid && time.Now().UTC().Sub(c.FinishedAt).Seconds() < 3 {
+ return nil
+ }
c.SetRunning(int(ei.Pid), false)
c.HasBeenManuallyStopped = false
c.HasBeenStartedBefore = true
--
2.23.0

View File

@ -222,4 +222,5 @@ patch/0225-docker-chrootarchive-don-t-create-parent-dirs-outside-of-ch.patch
patch/0226-docker-Lock-down-docker-root-dir-perms.patch
patch/0227-docker-registry-ensure-default-auth-config-has-address.patch
patch/0228-docker-fix-terminal-abnormal-after-docker-run.patch
patch/0229-docker-Add-an-ExitPid-field-for-State-struct-to-reco.patch
#end