containers / youki

A container runtime written in Rust

Home Page:https://containers.github.io/youki/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature request? allow customize the default cgroup root path

fengxsong opened this issue · comments

As mentioned in the title, there are some usage scenarios that require this capability. we want to build an agent that depends on the crate libcgroups, and we're trying to run it in container as a daemonset workload, so it must mount the host's cgroup root path /sys/fs/cgroup as something like /host/sys/fs/cgroup in the container filesystem.

I'm not sure how to implement this in the current code base. consider this as a feature request or proposal.

If this proposal is accepted, I'll submit a PR on it.

@fengxsong Thanks for your proposal.

It sounds good to me. But don't change the default path for cgroup. It means if the user doesn't pass the path of cgroup, we have to use /sys/fs/cgroup

Here is the default path for cgroup.

pub const DEFAULT_CGROUP_ROOT: &str = "/sys/fs/cgroup";

@utam0k is it ok to redefine the DEFAULT_CGROUP_PATH?

lazy_static! {
    pub static ref DEFAULT_CGROUP_ROOT: String =
        std::env::var("DEFAULT_CGROUP_ROOT").unwrap_or("/sys/fs/cgroup".to_string());
}

since type of DEFAULT_CGROUP_ROOT has changed from &str to String, then some refenced code will need to be changed.

@fengxsong No, please pass it from libcontainer's builder pattern.

@fengxsong can I ask you to make a PR updating docs and the migration guide regarding the changes done in #2411 , as it is part of public API of libcgroups ?

@fengxsong can I ask you to make a PR updating docs and the migration guide regarding the changes done in #2411 , as it is part of public API of libcgroups ?

sure, but would you mind pointing out which docs need to be updated?

https://github.com/containers/youki/blob/main/docs/src/user/libcgroups.md#common and https://github.com/containers/youki/blob/main/docs/src/developer/libcgroups.md ?

I'll make a PR later.

Closing as completed, docs are also done 👍