Open JCKeep opened 5 months ago
Thanks for your report, @JCKeep
the cpuacct,cpu and net_prio,net_cls was unsorted,
What does this mean? May I ask you to give me a more specific example or something?
@utam0k youki scan /proc/self/cgroup
to collect the cgroups, when call setup_emulated_subsystem
to bind mount cgroup subsystems, it will result in errors but not generate error.
for example, it may not mount net_cls,net_prio
subsystem, because my /proc/self/cgroup
is
[root@iZbp16aq5lgolei74n44yqZ ~]# cat /proc/self/cgroup
11:perf_event:/
10:freezer:/
9:memory:/
8:pids:/
7:devices:/
6:cpuacct,cpu:/
5:blkio:/
4:cpuset:/
3:hugetlb:/
2:net_prio,net_cls:/
1:name=systemd:/user.slice/user-0.slice/session-558.scope
in setup_emulated_subsystem
, it will search process_cgroups
by name "net_cls,net_prio", but it store "net_prio,net_cls"
#[cfg(feature = "v1")]
fn setup_emulated_subsystem(
&self,
cgroup_mount: &SpecMount,
options: &MountOptions,
subsystem_name: &str,
named: bool,
host_mount: &Path,
process_cgroups: &HashMap<String, String>,
) -> Result<()> {
tracing::debug!("Mounting (emulated) {:?} cgroup subsystem", subsystem_name);
let named_hierarchy: Cow<str> = if named {
format!("name={subsystem_name}").into()
} else {
subsystem_name.into()
};
// we search "net_cls,net_prio", but it store "net_prio,net_cls"
if let Some(proc_path) = process_cgroups.get(named_hierarchy.as_ref()) {
....
} else {
tracing::warn!("Could not mount {:?} cgroup subsystem", subsystem_name);
}
I understood this problem. I have a question. How does runc handle this case? Do you know?
@utam0k runc works
@JCKeep We should fix it, but I wonder how runc treats it.
@utam0k runc use the mount options of /proc/self/mountinfo
to get the cgroup subsystem mounts.
On my system, /proc/self/mountinfo
like:
the subsystem listed in /proc/self/cgroup
will match cgroup mount options.
such as:
@JCKeep Which code?
@utam0k you may have a look at function mountCgroupV1 and getCgroupMountsHelper
Why don't you align to runc's implementation?
I'm writing an oci runtime using some youki's source code by learning, and find some bugs.
On my system,
/proc/self/cgroup
file be like:the
cpuacct,cpu
andnet_prio,net_cls
was unsorted, so in functionmount_cgroup_v1
:process_cgroups
will recordcpuacct,cpu
andnet_prio,net_cls
, but system comount in namecpu,cpuacct
andnet_cls,net_prio
, so when usingsetup_emulated_subsystem
it find no subsystem to bind.So when I test, it will not mount some cgroupv1 subsystems and not generate error.
I fixed it on my system like this, mybe this will work for other system?