1 Star 0 Fork 58

gnaygnil/docker

forked from src-openEuler/docker 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0135-docker-delete-containerd-db-first-reboot.patch 2.57 KB
一键复制 编辑 原始数据 按行查看 历史
gnaygnil 提交于 2020-02-13 15:36 . docker: Fixed build error and URL
From cb7ce3076d0ae553bd2a2aa64a9be145c144d1ed Mon Sep 17 00:00:00 2001
From: jingrui <jingrui@huawei.com>
Date: Thu, 27 Jun 2019 17:07:21 +0800
Subject: [PATCH] docker: delete containerd db first reboot
Change-Id: I90b5e2217df47cef71a410e43188476be751cebe
Signed-off-by: jingrui <jingrui@huawei.com>
---
components/engine/cmd/dockerd/daemon.go | 1 +
components/engine/daemon/daemon.go | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/components/engine/cmd/dockerd/daemon.go b/components/engine/cmd/dockerd/daemon.go
index ea00c56fde..9c2b6602b3 100644
--- a/components/engine/cmd/dockerd/daemon.go
+++ b/components/engine/cmd/dockerd/daemon.go
@@ -185,6 +185,7 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
return fmt.Errorf("Error starting daemon: %v", err)
}
+ d.CleanupContainerdDBs()
d.StoreHosts(hosts)
// validate after NewDaemon has restored enabled plugins. Dont change order.
diff --git a/components/engine/daemon/daemon.go b/components/engine/daemon/daemon.go
index 72467eb62a..c36cc6395f 100644
--- a/components/engine/daemon/daemon.go
+++ b/components/engine/daemon/daemon.go
@@ -619,6 +619,20 @@ func (daemon *Daemon) cleanupLocalDB(db string) {
}
}
+func (daemon *Daemon) CleanupContainerdDBs() {
+ // check db lock is exist, do nothing if file is existed
+ dbLockPath := filepath.Join(daemon.configStore.ExecRoot, "dblock")
+ _, err := os.Stat(dbLockPath)
+ if err == nil {
+ return
+ }
+ if !os.IsNotExist(err) {
+ logrus.Errorf("stat dblock failed %v", err)
+ return
+ }
+ daemon.cleanupLocalDB(filepath.Join(daemon.configStore.Root, "containerd/daemon/io.containerd.metadata.v1.bolt/meta.db"))
+}
+
// DB files may corrupted on exception poweroff but can be rebuild at run time,
// so we can remove DB files on OS starts avoid daemon can not startup.
func (daemon *Daemon) cleanupLocalDBs() {
@@ -638,7 +652,6 @@ func (daemon *Daemon) cleanupLocalDBs() {
daemon.cleanupLocalDB(filepath.Join(daemon.configStore.Root, "builder/fscache.db"))
daemon.cleanupLocalDB(filepath.Join(daemon.configStore.Root, "volumes/metadata.db"))
daemon.cleanupLocalDB(filepath.Join(daemon.configStore.Root, "network/files/local-kv.db"))
- // daemon.cleanupLocalDB(filepath.Join(daemon.configStore.Root, "containerd/daemon/io.containerd.metadata.v1.bolt/meta.db"))
daemon.cleanupLocalDB(filepath.Join(daemon.configStore.Root, "accelerator/accel.db"))
daemon.cleanupLocalDB(filepath.Join(daemon.configStore.Root, "buildkit/metadata.db"))
daemon.cleanupLocalDB(filepath.Join(daemon.configStore.Root, "buildkit/cache.db"))
--
2.17.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gnaygnil/docker.git
git@gitee.com:gnaygnil/docker.git
gnaygnil
docker
docker
master

搜索帮助