mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
Merge pull request #87 from quanweiZhou/add-retry-for-rmdir
fix: support retry for rmdir cgroup path
This commit is contained in:
18
src/lib.rs
18
src/lib.rs
@@ -332,7 +332,23 @@ where
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
remove_dir(self.get_path())
|
||||
// Compatible with runC for remove dir operation
|
||||
// https://github.com/opencontainers/runc/blob/main/libcontainer/cgroups/utils.go#L272
|
||||
//
|
||||
// We trying to remove all paths five times with increasing delay between tries.
|
||||
// If after all there are not removed cgroups - appropriate error will be
|
||||
// returned.
|
||||
let mut delay = std::time::Duration::from_millis(10);
|
||||
let cgroup_path = self.get_path();
|
||||
for _i in 0..4 {
|
||||
if let Ok(()) = remove_dir(cgroup_path) {
|
||||
return Ok(());
|
||||
}
|
||||
std::thread::sleep(delay);
|
||||
delay *= 2;
|
||||
}
|
||||
|
||||
remove_dir(cgroup_path)
|
||||
}
|
||||
|
||||
/// Attach a task to this controller.
|
||||
|
||||
Reference in New Issue
Block a user