!147 [sync] PR-143: docker: cleanup netns file when stop docker daemon

From: @openeuler-sync-bot 
Reviewed-by: @duguhaotian 
Signed-off-by: @duguhaotian
This commit is contained in:
openeuler-ci-bot 2022-11-22 12:37:45 +00:00 committed by Gitee
commit da3fe4d2ae
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 46 additions and 1 deletions

View File

@ -1 +1 @@
18.09.0.244
18.09.0.245

View File

@ -199,6 +199,12 @@ fi
%endif
%changelog
* Tue Nov 22 2022 chenjiankun<chenjiankun1@huawei.com> - 18.09.0-245
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:cleanup netns file when stop docker daemon
* Sat Oct 15 2022 DCCooper <1866858@gmail.com> - 18.09.0-244
- Type:bugfix
- CVE:NA

View File

@ -0,0 +1,38 @@
From 26f9b14362ee9859e221e73e57b73abbe7f812f8 Mon Sep 17 00:00:00 2001
From: chenjiankun <chenjiankun1@huawei.com>
Date: Thu, 8 Sep 2022 20:41:30 +0800
Subject: [PATCH] docker: cleanup netns file when close docker daemon
When the docker daemon shutdown, if LiveRestoreEnabled is true and
there are containers still running, we will not call the netns GC
and will cause netns file leak. We need to call netns GC manually.
---
components/engine/daemon/daemon.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/components/engine/daemon/daemon.go b/components/engine/daemon/daemon.go
index 5c6be8e45..6e3477bf5 100644
--- a/components/engine/daemon/daemon.go
+++ b/components/engine/daemon/daemon.go
@@ -70,6 +70,7 @@ import (
"github.com/docker/libnetwork"
"github.com/docker/libnetwork/cluster"
nwconfig "github.com/docker/libnetwork/config"
+ "github.com/docker/libnetwork/osl"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
)
@@ -1295,6 +1296,10 @@ func (daemon *Daemon) ShutdownTimeout() int {
// Shutdown stops the daemon.
func (daemon *Daemon) Shutdown() error {
daemon.shutdown = true
+
+ // netns file in GC need some cleanup first
+ osl.GC()
+
// Keep mounts and networking running on daemon shutdown if
// we are to keep containers running and restore them.
--
2.23.0

View File

@ -225,4 +225,5 @@ patch/0228-docker-fix-terminal-abnormal-after-docker-run.patch
patch/0229-docker-Add-an-ExitPid-field-for-State-struct-to-reco.patch
patch/0230-docker-AdditionalGids-must-include-effective-group-I.patch
patch/0231-docker-ensure-layer-digest-folder-removed-if-ls.driv.patch
patch/0232-docker-cleanup-netns-file-when-close-docker-daemon.patch
#end