From ca3e9f27f63aefe8a5c2f527460fc35ff24e5429 Mon Sep 17 00:00:00 2001 From: Furisto <24721048+Furisto@users.noreply.github.com> Date: Mon, 7 Jun 2021 18:23:47 +0200 Subject: [PATCH 1/2] Handle relative cgroup paths --- integration_test.sh | 7 ++++++- src/cgroups/v1/manager.rs | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/integration_test.sh b/integration_test.sh index a5a11fffb..37d3c29b7 100755 --- a/integration_test.sh +++ b/integration_test.sh @@ -3,7 +3,12 @@ root=$(pwd) cd integration_test/src/github.com/opencontainers/runtime-tools GOPATH=$root/integration_test make runtimetest validation-executables -test_cases=("default/default.t" "linux_cgroups_devices/linux_cgroups_devices.t" "linux_cgroups_hugetlb/linux_cgroups_hugetlb.t" "linux_cgroups_pids/linux_cgroups_pids.t" "linux_cgroups_memory/linux_cgroups_memory.t" "linux_cgroups_network/linux_cgroups_network.t" "linux_cgroups_cpus/linux_cgroups_cpus.t") +test_cases=("default/default.t" "linux_cgroups_devices/linux_cgroups_devices.t" "linux_cgroups_hugetlb/linux_cgroups_hugetlb.t" +"linux_cgroups_pids/linux_cgroups_pids.t" "linux_cgroups_memory/linux_cgroups_memory.t" "linux_cgroups_network/linux_cgroups_network.t" +"linux_cgroups_cpus/linux_cgroups_cpus.t" "linux_cgroups_relative_cpus/linux_cgroups_relative_cpus.t" +"linux_cgroups_relative_devices/linux_cgroups_relative_devices.t" "linux_cgroups_relative_hugetlb/linux_cgroups_relative_hugetlb.t" +"linux_cgroups_relative_memory/linux_cgroups_relative_memory.t" "linux_cgroups_relative_network/linux_cgroups_relative_network.t" +"linux_cgroups_relative_pids/linux_cgroups_relative_pids.t") for case in "${test_cases[@]}"; do echo "Running $case" if [ 0 -ne $(sudo RUST_BACKTRACE=1 YOUKI_LOG_LEVEL=debug RUNTIME=$root/youki $root/integration_test/src/github.com/opencontainers/runtime-tools/validation/$case | grep "not ok" | wc -l) ]; then diff --git a/src/cgroups/v1/manager.rs b/src/cgroups/v1/manager.rs index 86dd8268e..49c51df6e 100644 --- a/src/cgroups/v1/manager.rs +++ b/src/cgroups/v1/manager.rs @@ -80,8 +80,10 @@ impl Manager { mount .mount_point .join_absolute_path(Path::new(&cgroup.pathname))? - } else { + } else if cgroup_path.is_absolute() { mount.mount_point.join_absolute_path(&cgroup_path)? + } else { + mount.mount_point.join(cgroup_path) }; Ok(p) From b9ae5b7cd67a7a635954e4711f89e560c38ff6ca Mon Sep 17 00:00:00 2001 From: Furisto <24721048+Furisto@users.noreply.github.com> Date: Wed, 9 Jun 2021 20:19:36 +0200 Subject: [PATCH 2/2] Ensure parents have value --- src/cgroups/v1/cpuset.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cgroups/v1/cpuset.rs b/src/cgroups/v1/cpuset.rs index 2d7342dd9..e989e5aa0 100644 --- a/src/cgroups/v1/cpuset.rs +++ b/src/cgroups/v1/cpuset.rs @@ -18,13 +18,13 @@ impl Controller for CpuSet { log::debug!("Apply CpuSet cgroup config"); fs::create_dir_all(cgroup_path)?; + Self::ensure_not_empty(cgroup_path, CGROUP_CPUSET_CPUS)?; + Self::ensure_not_empty(cgroup_path, CGROUP_CPUSET_MEMS)?; + if let Some(cpuset) = &linux_resources.cpu { Self::apply(cgroup_path, cpuset)?; } - Self::ensure_not_empty(cgroup_path, CGROUP_CPUSET_CPUS)?; - Self::ensure_not_empty(cgroup_path, CGROUP_CPUSET_MEMS)?; - common::write_cgroup_file(cgroup_path.join(CGROUP_PROCS), pid)?; Ok(()) }