Skip to content

Commit

Permalink
Set cgroups path for tenant containers from main container
Browse files Browse the repository at this point in the history
  • Loading branch information
YJDoc2 committed Feb 16, 2024
1 parent 762a2e8 commit 9dca72e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions crates/libcgroups/src/systemd/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ impl CgroupManager for Manager {
if pid.as_raw() == -1 {

Check warning on line 353 in crates/libcgroups/src/systemd/manager.rs

View workflow job for this annotation

GitHub Actions / check (aarch64, musl)

Diff in /home/runner/work/youki/youki/crates/libcgroups/src/systemd/manager.rs

Check warning on line 353 in crates/libcgroups/src/systemd/manager.rs

View workflow job for this annotation

GitHub Actions / check (aarch64, musl)

Diff in /home/runner/work/youki/youki/crates/libcgroups/src/systemd/manager.rs
return Ok(());
}
if self.client.transient_unit_exists(&self.unit_name){
tracing::debug!("Transient unit {:?} already exists",self.unit_name);
return Ok(());
}

tracing::debug!("Starting {:?}", self.unit_name);
self.client.start_transient_unit(
Expand Down
8 changes: 6 additions & 2 deletions crates/libcontainer/src/container/tenant_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,14 @@ impl TenantContainerBuilder {
));
}

let linux = spec.linux().as_ref().unwrap();

Check warning on line 330 in crates/libcontainer/src/container/tenant_builder.rs

View workflow job for this annotation

GitHub Actions / check (aarch64, musl)

Diff in /home/runner/work/youki/youki/crates/libcontainer/src/container/tenant_builder.rs

Check warning on line 330 in crates/libcontainer/src/container/tenant_builder.rs

View workflow job for this annotation

GitHub Actions / check (aarch64, musl)

Diff in /home/runner/work/youki/youki/crates/libcontainer/src/container/tenant_builder.rs
let init_process = procfs::process::Process::new(container.pid().unwrap().as_raw())?;
let ns = self.get_namespaces(init_process.namespaces()?.0)?;
let linux = LinuxBuilder::default().namespaces(ns).build()?;

let linux = if linux.cgroups_path().is_some(){
LinuxBuilder::default().namespaces(ns).cgroups_path(linux.cgroups_path().as_ref().unwrap().clone()).build()?
}else{
LinuxBuilder::default().namespaces(ns).build()?
};
spec.set_process(Some(process)).set_linux(Some(linux));
Ok(())
}
Expand Down

0 comments on commit 9dca72e

Please sign in to comment.