docker: fix container missing after restarting dockerd twice
fix #I6MJ4X
This commit is contained in:
parent
e27fa15f52
commit
5ecf0ca3e7
@ -1 +1 @@
|
|||||||
18.09.0.318
|
18.09.0.319
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
Name: docker-engine
|
Name: docker-engine
|
||||||
Version: 18.09.0
|
Version: 18.09.0
|
||||||
Release: 318
|
Release: 319
|
||||||
Epoch: 2
|
Epoch: 2
|
||||||
Summary: The open-source application container engine
|
Summary: The open-source application container engine
|
||||||
Group: Tools/Docker
|
Group: Tools/Docker
|
||||||
@ -213,6 +213,12 @@ fi
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Mar 14 2023 JackChan8<chenjiankun1@huawei.com> - 18.09.0-319
|
||||||
|
- Type:bugfix
|
||||||
|
- CVE:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:fix container missing after restarting dockerd twice
|
||||||
|
|
||||||
* Fri Mar 10 2023 Song Zhang<zhangsong34@huawei.com> - 18.09.0-318
|
* Fri Mar 10 2023 Song Zhang<zhangsong34@huawei.com> - 18.09.0-318
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- CVE:NA
|
- CVE:NA
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
0b9bbc0a1c50c5b83c48e3fca9162cf673705d92
|
125a5369ebd1d5b7c96d8902bd1c9d195d90d5b7
|
||||||
|
|||||||
@ -0,0 +1,62 @@
|
|||||||
|
From 199481834e9e8e1ab4debaae737f372ac295af22 Mon Sep 17 00:00:00 2001
|
||||||
|
From: chenjiankun <chenjiankun1@huawei.com>
|
||||||
|
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
|
||||||
|
|
||||||
@ -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/0235-docker-do-not-stop-health-check-before-sending-signa.patch
|
||||||
patch/0236-docker-set-freezer.state-to-Thawed-to-increase-freez.patch
|
patch/0236-docker-set-freezer.state-to-Thawed-to-increase-freez.patch
|
||||||
patch/0237-docker-stats-fix-panic.patch
|
patch/0237-docker-stats-fix-panic.patch
|
||||||
|
patch/0238-docker-fix-container-missing-after-restarting-docker.patch
|
||||||
#end
|
#end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user