diff --git a/crates/libcgroups/src/systemd/manager.rs b/crates/libcgroups/src/systemd/manager.rs index ca4e2fe6de..295dcb96da 100644 --- a/crates/libcgroups/src/systemd/manager.rs +++ b/crates/libcgroups/src/systemd/manager.rs @@ -353,6 +353,10 @@ impl CgroupManager for Manager { if pid.as_raw() == -1 { 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( diff --git a/crates/libcontainer/src/container/tenant_builder.rs b/crates/libcontainer/src/container/tenant_builder.rs index a503cc6ff8..86192141d4 100644 --- a/crates/libcontainer/src/container/tenant_builder.rs +++ b/crates/libcontainer/src/container/tenant_builder.rs @@ -327,10 +327,14 @@ impl TenantContainerBuilder { )); } + let linux = spec.linux().as_ref().unwrap(); 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(()) }