1 Star 0 Fork 46

jake/src-openEuler-iSulad

forked from src-openEuler/iSulad 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0040-fix-cpurt-init-bug-for-systemd-cgroup.patch 3.14 KB
一键复制 编辑 原始数据 按行查看 历史
jake 提交于 2024-04-02 11:50 . upgrade from upstream
From fe11b34a3c2843ea2198b310160b182d63aeb63b Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Tue, 2 Apr 2024 11:22:09 +0800
Subject: [PATCH 40/43] fix cpurt init bug for systemd-cgroup
Signed-off-by: jikai <jikai11@huawei.com>
---
src/daemon/common/cgroup/cgroup.c | 13 +++++++------
src/daemon/executor/container_cb/execution.c | 13 +++++++------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/daemon/common/cgroup/cgroup.c b/src/daemon/common/cgroup/cgroup.c
index d3f1445a..007dbb70 100644
--- a/src/daemon/common/cgroup/cgroup.c
+++ b/src/daemon/common/cgroup/cgroup.c
@@ -146,17 +146,18 @@ char *common_convert_cgroup_path(const char *cgroup_path)
return NULL;
}
- // for cgroup fs cgroup path, return directly
- if (!util_has_suffix(cgroup_path, ".slice")) {
- return util_strdup_s(cgroup_path);
- }
-
// for systemd cgroup, cgroup_path should have the form slice:prefix:id,
// convert it to a true path, such as from test-a.slice:isulad:id
// to test.slice/test-a.slice/isulad-id.scope
arr = util_string_split_n(cgroup_path, ':', 3);
if (arr == NULL || util_array_len((const char **)arr) != 3) {
- ERROR("Invalid systemd cgroup parent");
+ // not a systemd cgroup, return cgroup path directly
+ return util_strdup_s(cgroup_path);
+ }
+
+ // for cgroup fs cgroup path, return directly
+ if (!util_has_suffix(arr[0], ".slice")) {
+ ERROR("Invalid systemd cgroup path: %s", cgroup_path);
return NULL;
}
diff --git a/src/daemon/executor/container_cb/execution.c b/src/daemon/executor/container_cb/execution.c
index 88c6b354..4bf3621d 100644
--- a/src/daemon/executor/container_cb/execution.c
+++ b/src/daemon/executor/container_cb/execution.c
@@ -435,11 +435,12 @@ static int cpurt_controller_init(const char *id, const host_config *host_spec)
}
if (conf_get_systemd_cgroup()) {
- // currently it is the same as docker, yet it is unclear that
- // if systemd cgroup is used and cgroup parent is set to a slice rather than system.slice
- // should iSulad set cpu.rt_runtime_us and cpu.rt_period_us for the parent path?
- // in fact, even if system.slice is used,
- // cpu.rt_runtime_us and cpu.rt_period_us might still needed to be set manually
+ __isula_auto_free char *converted_cgroup = common_convert_cgroup_path(cgroups_path);
+ if (converted_cgroup == NULL) {
+ ERROR("Failed to convert cgroup path");
+ return -1;
+ }
+
__isula_auto_free char *init_cgroup = common_get_init_cgroup_path("cpu");
if (init_cgroup == NULL) {
ERROR("Failed to get init cgroup");
@@ -451,7 +452,7 @@ static int cpurt_controller_init(const char *id, const host_config *host_spec)
ERROR("Failed to get own cgroup");
return -1;
}
- char *new_cgroups_path = util_path_join(init_cgroup, cgroups_path);
+ char *new_cgroups_path = util_path_join(init_cgroup, converted_cgroup);
if (new_cgroups_path == NULL) {
ERROR("Failed to join path");
return -1;
--
2.34.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jikai11/src-openEuler-iSulad.git
git@gitee.com:jikai11/src-openEuler-iSulad.git
jikai11
src-openEuler-iSulad
src-openEuler-iSulad
master

搜索帮助