代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/syscontainer-tools 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 7581283eb8e235ae0923e8c68677e059895a3c9b Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 17 Aug 2023 20:12:49 +0800
Subject: [PATCH] clean up run/syscontainer-tools/netns/containerid dir residue
Signed-off-by: yangjiaqi <yangjiaqi16@huawei.com>
---
hooks/syscontainer-hooks/prestart.go | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/hooks/syscontainer-hooks/prestart.go b/hooks/syscontainer-hooks/prestart.go
index a71d26b..8b5756e 100644
--- a/hooks/syscontainer-hooks/prestart.go
+++ b/hooks/syscontainer-hooks/prestart.go
@@ -23,11 +23,13 @@ import (
"strconv"
"strings"
+ "github.com/docker/docker/pkg/mount"
"github.com/opencontainers/runc/libcontainer/configs"
_ "github.com/opencontainers/runc/libcontainer/nsenter"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
+
hconfig "isula.org/syscontainer-tools/config"
"isula.org/syscontainer-tools/libdevice"
"isula.org/syscontainer-tools/libdevice/nsexec"
@@ -251,7 +253,25 @@ func UpdateNetwork(state *configs.HookState, hookConfig *hconfig.ContainerHookCo
logrus.Errorf("[device-hook] Failed to Create netns dir %v", err)
return err
}
- file, err := os.Create(filepath.Join(hconfig.IsuladToolsDirNetns, state.ID))
+ /*
+ each container can only be in prestart, running or poststop at the same time,
+ so there is no lock protection for the file /run/syscontainer-tools/netns/containerid.
+ */
+ netnsMountpoint := filepath.Join(hconfig.IsuladToolsDirNetns, state.ID)
+ // see if the current network namespace file is mounted
+ mounted, err := mount.Mounted(netnsMountpoint)
+ if err != nil {
+ logrus.Errorf("[device-hook] Failed to get mount info %v: %v", netnsMountpoint, err)
+ }
+ // has mounted
+ if mounted {
+ // maybe the previous poststop command was not executed or interrupted, resulting in residual
+ if removeErr := RemoveNetworkDevices(state, hookConfig, spec); removeErr != nil {
+ logrus.Errorf("[device-hook] Failed to remove network devices and umount netns file and %v is still mounted: %v",
+ netnsMountpoint, removeErr)
+ }
+ }
+ file, err := os.Create(netnsMountpoint)
if err != nil {
logrus.Errorf("[device-hook] Failed to Create netns file %v", err)
return err
--
2.30.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。