Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle relative cgroup paths #74

Merged
merged 2 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/cgroups/v1/cpuset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
4 changes: 3 additions & 1 deletion src/cgroups/v1/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down