From 5ecf0ca3e74f004180222c8ec9ea3e240bf96d15 Mon Sep 17 00:00:00 2001 From: JackChan8 Date: Tue, 14 Mar 2023 19:27:35 +0800 Subject: [PATCH] docker: fix container missing after restarting dockerd twice fix #I6MJ4X --- VERSION-vendor | 2 +- docker.spec | 8 ++- git-commit | 2 +- ...iner-missing-after-restarting-docker.patch | 62 +++++++++++++++++++ series.conf | 1 + 5 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 patch/0238-docker-fix-container-missing-after-restarting-docker.patch diff --git a/VERSION-vendor b/VERSION-vendor index 6be0a4a..80be9de 100644 --- a/VERSION-vendor +++ b/VERSION-vendor @@ -1 +1 @@ -18.09.0.318 +18.09.0.319 diff --git a/docker.spec b/docker.spec index ed95ed3..d83e9ba 100644 --- a/docker.spec +++ b/docker.spec @@ -1,6 +1,6 @@ Name: docker-engine Version: 18.09.0 -Release: 318 +Release: 319 Epoch: 2 Summary: The open-source application container engine Group: Tools/Docker @@ -213,6 +213,12 @@ fi %endif %changelog +* Tue Mar 14 2023 JackChan8 - 18.09.0-319 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:fix container missing after restarting dockerd twice + * Fri Mar 10 2023 Song Zhang - 18.09.0-318 - Type:bugfix - CVE:NA diff --git a/git-commit b/git-commit index 962313f..2532a5c 100644 --- a/git-commit +++ b/git-commit @@ -1 +1 @@ -0b9bbc0a1c50c5b83c48e3fca9162cf673705d92 +125a5369ebd1d5b7c96d8902bd1c9d195d90d5b7 diff --git a/patch/0238-docker-fix-container-missing-after-restarting-docker.patch b/patch/0238-docker-fix-container-missing-after-restarting-docker.patch new file mode 100644 index 0000000..7be68ba --- /dev/null +++ b/patch/0238-docker-fix-container-missing-after-restarting-docker.patch @@ -0,0 +1,62 @@ +From 199481834e9e8e1ab4debaae737f372ac295af22 Mon Sep 17 00:00:00 2001 +From: chenjiankun +Date: Fri, 17 Feb 2023 15:06:07 +0800 +Subject: [PATCH] docker: fix container missing after restarting dockerd twice + +when restart dockerd and restore containers, if "no space left on device" +in /var/lib/docker, daemon.Register will failed, and then dockerd will +cleanup the init and rootfs layer. then if we restart dockerd again, dockerd +will remove container dir for daemon.imageService.GetLayerByID failed. Then +the container will disappear forever. +--- + components/engine/daemon/container.go | 12 +++++++++++- + components/engine/daemon/daemon.go | 15 ++++++++++----- + 2 files changed, 21 insertions(+), 6 deletions(-) + +diff --git a/components/engine/daemon/daemon.go b/components/engine/daemon/daemon.go +index 6e3477bf5..96cfb14bf 100644 +--- a/components/engine/daemon/daemon.go ++++ b/components/engine/daemon/daemon.go +@@ -311,10 +311,17 @@ func (daemon *Daemon) restore() error { + removeContainers := make(map[string]*container.Container) + restartContainers := make(map[*container.Container]chan struct{}) + activeSandboxes := make(map[string]interface{}) ++ ++ containerIDs := make(map[string]struct{}) ++ for cid, _ := range containers { ++ containerIDs[cid] = struct{}{} ++ } ++ + for id, c := range containers { + if err := daemon.registerName(c); err != nil { + logrus.Errorf("Failed to register container name %s: %s", c.ID, err) + delete(containers, id) ++ delete(containerIDs, id) + continue + } + +@@ -325,6 +332,9 @@ func (daemon *Daemon) restore() error { + if err := daemon.Register(c); err != nil { + logrus.Errorf("Failed to register container %s: %s", c.ID, err) + delete(containers, id) ++ if !strings.Contains(err.Error(), "no space left on device") { ++ delete(containerIDs, id) ++ } + continue + } + +@@ -528,11 +538,6 @@ func (daemon *Daemon) restore() error { + logrus.Errorf("removeRedundantMounts failed %v", err) + } + +- containerIDs := make(map[string]struct{}) +- for cid, _ := range containers { +- containerIDs[cid] = struct{}{} +- } +- + err = daemon.imageService.LayerStoreForOS(runtime.GOOS).CleanupRedundant(containerIDs) + if err != nil { + logrus.Errorf("cleanup redundant IDs in layerStore failed %s", err) +-- +2.33.0 + diff --git a/series.conf b/series.conf index f91922f..e4eba83 100644 --- a/series.conf +++ b/series.conf @@ -235,4 +235,5 @@ patch/0234-docker-Read-connection-marking-information-from-CT-f.patch patch/0235-docker-do-not-stop-health-check-before-sending-signa.patch patch/0236-docker-set-freezer.state-to-Thawed-to-increase-freez.patch patch/0237-docker-stats-fix-panic.patch +patch/0238-docker-fix-container-missing-after-restarting-docker.patch #end