!280 do not operate playload and attach cgroup if no controller found

From: @wangfengtu 
Reviewed-by: @duguhaotian, @jingwoo 
Signed-off-by: @jingwoo
This commit is contained in:
openeuler-ci-bot 2022-05-23 12:27:07 +00:00 committed by Gitee
commit f9942b5d36
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 138 additions and 1 deletions

View File

@ -0,0 +1,128 @@
From c080da6dda7a47de8ccb5cc3eabec6e5b2e4c649 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Mon, 23 May 2022 19:00:28 +0800
Subject: [PATCH] do not operate playload and attach cgroup if no controller
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
src/lxc/cgroups/cgroup.h | 1 +
src/lxc/cgroups/isulad_cgfsng.c | 48 ++++++++++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/src/lxc/cgroups/cgroup.h b/src/lxc/cgroups/cgroup.h
index a9048c4..8b18c1e 100644
--- a/src/lxc/cgroups/cgroup.h
+++ b/src/lxc/cgroups/cgroup.h
@@ -104,6 +104,7 @@ struct cgroup_ops {
#ifdef HAVE_ISULAD
int errfd;
+ bool no_controller;
#endif
/* @hierarchies
diff --git a/src/lxc/cgroups/isulad_cgfsng.c b/src/lxc/cgroups/isulad_cgfsng.c
index 576b424..8a9656a 100644
--- a/src/lxc/cgroups/isulad_cgfsng.c
+++ b/src/lxc/cgroups/isulad_cgfsng.c
@@ -677,6 +677,13 @@ __cgfsng_ops static bool isulad_cgfsng_payload_destroy(struct cgroup_ops *ops,
return false;
}
+#ifdef HAVE_ISULAD
+ if (ops->no_controller) {
+ DEBUG("no controller found, isgnore isulad_cgfsng_payload_destroy");
+ return true;
+ }
+#endif
+
if (!ops->hierarchies) {
return false;
}
@@ -934,6 +941,13 @@ __cgfsng_ops static inline bool isulad_cgfsng_payload_create(struct cgroup_ops *
int i;
char *container_cgroup = ops->container_cgroup;
+#ifdef HAVE_ISULAD
+ if (ops->no_controller) {
+ DEBUG("no controller found, isgnore isulad_cgfsng_payload_create");
+ return true;
+ }
+#endif
+
if (!container_cgroup) {
ERROR("cgfsng_create container_cgroup is invalid");
return false;
@@ -964,6 +978,13 @@ __cgfsng_ops static bool isulad_cgfsng_payload_enter(struct cgroup_ops *ops,
if (!ops)
return ret_set_errno(false, ENOENT);
+#ifdef HAVE_ISULAD
+ if (ops->no_controller) {
+ DEBUG("no controller found, isgnore isulad_cgfsng_payload_enter");
+ return true;
+ }
+#endif
+
if (!ops->hierarchies)
return true;
@@ -1121,6 +1142,13 @@ __cgfsng_ops void isulad_cgfsng_payload_finalize(struct cgroup_ops *ops)
if (!ops)
return;
+#ifdef HAVE_ISULAD
+ if (ops->no_controller) {
+ DEBUG("no controller found, isgnore isulad_cgfsng_payload_finalize");
+ return;
+ }
+#endif
+
if (!ops->hierarchies)
return;
@@ -2010,6 +2038,13 @@ __cgfsng_ops static bool isulad_cgfsng_attach(struct cgroup_ops *ops,
if (!ops)
return ret_set_errno(false, ENOENT);
+#ifdef HAVE_ISULAD
+ if (ops->no_controller) {
+ DEBUG("no controller found, isgnore isulad_cgfsng_attach");
+ return true;
+ }
+#endif
+
if (!ops->hierarchies)
return true;
@@ -2781,6 +2816,13 @@ __cgfsng_ops bool isulad_cgfsng_payload_delegate_controllers(struct cgroup_ops *
if (!ops)
return ret_set_errno(false, ENOENT);
+#ifdef HAVE_ISULAD
+ if (ops->no_controller) {
+ DEBUG("no controller found, isgnore isulad_cgfsng_payload_delegate_controllers");
+ return true;
+ }
+#endif
+
return __cgfsng_delegate_controllers(ops, ops->container_cgroup);
}
@@ -3041,8 +3083,12 @@ static int cg_unified_init(struct cgroup_ops *ops, bool relative,
delegatable = cg_unified_get_controllers(subtree_path);
if (!delegatable)
delegatable = cg_unified_make_empty_controller();
- if (!delegatable[0])
+ if (!delegatable[0]) {
TRACE("No controllers are enabled for delegation");
+#ifdef HAVE_ISULAD
+ ops->no_controller = true;
+#endif
+ }
/* TODO: If the user requested specific controllers via lxc.cgroup.use
* we should verify here. The reason I'm not doing it right is that I'm
--
2.25.1

View File

@ -1,4 +1,4 @@
%global _release 2022052101 %global _release 2022052301
Name: lxc Name: lxc
Version: 4.0.3 Version: 4.0.3
@ -50,6 +50,7 @@ Patch0039: 0039-fix-bug-of-memory-free.patch
Patch0040: 0040-refactor-the-way-to-convert-selinux-label-to-shared.path Patch0040: 0040-refactor-the-way-to-convert-selinux-label-to-shared.path
Patch0041: 0041-do-not-free-the-pointer-returned-by-dirname.patch Patch0041: 0041-do-not-free-the-pointer-returned-by-dirname.patch
Patch0042: 0042-add-x-permission-when-create-directory.patch Patch0042: 0042-add-x-permission-when-create-directory.patch
Patch0043: 0043-do-not-operate-playload-and-attach-cgroup-if-no-cont.patch
BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath
BuildRequires: pkgconfig(libseccomp) BuildRequires: pkgconfig(libseccomp)
@ -221,6 +222,12 @@ make check
%{_mandir}/*/man7/%{name}* %{_mandir}/*/man7/%{name}*
%changelog %changelog
* Mon May 23 2022 wangfengtu<wangfengtu@huawei.com> - 4.0.3-2022052301
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: do not operate playload and attach cgroup if no controller found
* Sat May 21 2022 wangfengtu<wangfengtu@huawei.com> - 4.0.3-2022052101 * Sat May 21 2022 wangfengtu<wangfengtu@huawei.com> - 4.0.3-2022052101
- Type:bugfix - Type:bugfix
- ID:NA - ID:NA

View File

@ -39,3 +39,5 @@
0039-fix-bug-of-memory-free.patch 0039-fix-bug-of-memory-free.patch
0040-refactor-the-way-to-convert-selinux-label-to-shared.path 0040-refactor-the-way-to-convert-selinux-label-to-shared.path
0041-do-not-free-the-pointer-returned-by-dirname.patch 0041-do-not-free-the-pointer-returned-by-dirname.patch
0042-add-x-permission-when-create-directory.patch
0043-do-not-operate-playload-and-attach-cgroup-if-no-cont.patch