From e1596f7abf7991a76a78fe96de055cb2a422e06d Mon Sep 17 00:00:00 2001 From: Zvonko Kaiser Date: Thu, 23 Jan 2025 03:53:32 +0000 Subject: [PATCH] agent: Add option to parse cgroup_no_v1 For AGENT_INIT=yes we do not run systemd and hence systemd.unified_... does not mean anything to other init systems. Providing cgroup_no_v1=all is enough to signal other init systemd to use cgroupV2. Signed-off-by: Zvonko Kaiser --- src/agent/src/config.rs | 12 ++++++++++++ src/agent/src/main.rs | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/agent/src/config.rs b/src/agent/src/config.rs index 2858a570b8..5203fcedf0 100644 --- a/src/agent/src/config.rs +++ b/src/agent/src/config.rs @@ -26,6 +26,7 @@ const CDH_API_TIMOUT_OPTION: &str = "agent.cdh_api_timeout"; const DEBUG_CONSOLE_VPORT_OPTION: &str = "agent.debug_console_vport"; const LOG_VPORT_OPTION: &str = "agent.log_vport"; const CONTAINER_PIPE_SIZE_OPTION: &str = "agent.container_pipe_size"; +const CGROUP_NO_V1: &str = "cgroup_no_v1"; const UNIFIED_CGROUP_HIERARCHY_OPTION: &str = "systemd.unified_cgroup_hierarchy"; const CONFIG_FILE: &str = "agent.config_file"; const GUEST_COMPONENTS_REST_API_OPTION: &str = "agent.guest_components_rest_api"; @@ -136,6 +137,7 @@ pub struct AgentConfig { pub container_pipe_size: i32, pub server_addr: String, pub passfd_listener_port: i32, + pub cgroup_no_v1: String, pub unified_cgroup_hierarchy: bool, pub tracing: bool, pub supports_seccomp: bool, @@ -271,6 +273,7 @@ impl Default for AgentConfig { container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE, server_addr: format!("{}:{}", VSOCK_ADDR, DEFAULT_AGENT_VSOCK_PORT), passfd_listener_port: 0, + cgroup_no_v1: String::from(""), unified_cgroup_hierarchy: false, tracing: false, supports_seccomp: rpc::have_seccomp(), @@ -514,6 +517,13 @@ impl AgentConfig { config.container_pipe_size, get_container_pipe_size ); + parse_cmdline_param!( + param, + CGROUP_NO_V1, + config.cgroup_no_v1, + get_string_value, + | no_v1 | no_v1 == "all" + ); parse_cmdline_param!( param, UNIFIED_CGROUP_HIERARCHY_OPTION, @@ -898,6 +908,7 @@ mod tests { hotplug_timeout: time::Duration, container_pipe_size: i32, server_addr: &'a str, + cgroup_no_v1: &'a str, unified_cgroup_hierarchy: bool, tracing: bool, https_proxy: &'a str, @@ -927,6 +938,7 @@ mod tests { hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT, container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE, server_addr: TEST_SERVER_ADDR, + cgroup_no_v1: "", unified_cgroup_hierarchy: false, tracing: false, https_proxy: "", diff --git a/src/agent/src/main.rs b/src/agent/src/main.rs index c4df5f4aec..f8a1a24da2 100644 --- a/src/agent/src/main.rs +++ b/src/agent/src/main.rs @@ -228,8 +228,9 @@ async fn real_main(init_mode: bool) -> std::result::Result<(), Box