From 15cbc545ca1f1c6ddc53734eac1221d3ba2d6fff Mon Sep 17 00:00:00 2001 From: Fupan Li Date: Thu, 22 May 2025 12:05:27 +0800 Subject: [PATCH] runtime-rs: fix the issue of delete cgroup failed When try to delete a cgroup, it's needed to move all of the tasks/procs in the cgroup into root cgroup and then delete it. Since for cgroup v2, it doesn't support to move thread into root cgroup, thus move the processes instead of moving tasks can fix this issue. Signed-off-by: Fupan Li --- src/runtime-rs/crates/resource/src/cgroups/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime-rs/crates/resource/src/cgroups/mod.rs b/src/runtime-rs/crates/resource/src/cgroups/mod.rs index 47b56f9b0b..7dfe037fdf 100644 --- a/src/runtime-rs/crates/resource/src/cgroups/mod.rs +++ b/src/runtime-rs/crates/resource/src/cgroups/mod.rs @@ -123,11 +123,11 @@ impl CgroupsResource { /// delete will move the running processes in the cgroup_manager and /// overhead_cgroup_manager to the parent and then delete the cgroups. pub async fn delete(&self) -> Result<()> { - for cg_pid in self.cgroup_manager.tasks() { - // For now, we can't guarantee that the thread in cgroup_manager does still - // exist. Once it exit, we should ignore that error returned by remove_task + for cg_pid in self.cgroup_manager.procs() { + // For now, we can't guarantee that the process in cgroup_manager does still + // exist. Once it exit, we should ignore that error returned by remove_task_by_tgid // to let it go. - if let Err(error) = self.cgroup_manager.remove_task(cg_pid) { + if let Err(error) = self.cgroup_manager.remove_task_by_tgid(cg_pid) { match error.source() { Some(err) => match err.downcast_ref::() { Some(e) => {