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 <zkaiser@nvidia.com>
This commit is contained in:
Zvonko Kaiser
2025-01-23 03:53:32 +00:00
parent 311c3638c6
commit e1596f7abf
2 changed files with 14 additions and 1 deletions

View File

@@ -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: "",

View File

@@ -228,8 +228,9 @@ async fn real_main(init_mode: bool) -> std::result::Result<(), Box<dyn std::erro
})?;
lazy_static::initialize(&AGENT_CONFIG);
let cgroup_v2 = AGENT_CONFIG.unified_cgroup_hierarchy || AGENT_CONFIG.cgroup_no_v1 == "all";
init_agent_as_init(&logger, AGENT_CONFIG.unified_cgroup_hierarchy)?;
init_agent_as_init(&logger, cgroup_v2)?;
drop(logger_async_guard);
} else {
lazy_static::initialize(&AGENT_CONFIG);