mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 12:44:39 +00:00
runtime-rs: neglect a certain error when delete cgroup
Delete cgroup for a thread which may exit can lead to panic. Just neglect that error is harmless also avoid this failure. Fixes: #6192 Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
This commit is contained in:
parent
8ae14f6a55
commit
ab59a65c92
@ -9,6 +9,8 @@ mod utils;
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
error::Error,
|
||||
io,
|
||||
iter::FromIterator,
|
||||
sync::Arc,
|
||||
};
|
||||
@ -24,6 +26,8 @@ use oci::LinuxResources;
|
||||
use persist::sandbox_persist::Persist;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
const OS_ERROR_NO_SUCH_PROCESS: i32 = 3;
|
||||
|
||||
pub struct CgroupArgs {
|
||||
pub sid: String,
|
||||
pub config: TomlConfig,
|
||||
@ -109,7 +113,22 @@ impl CgroupsResource {
|
||||
/// 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() {
|
||||
self.cgroup_manager.remove_task(cg_pid)?;
|
||||
// For now, we can't guarantee that the thread in cgroup_manager does still
|
||||
// exist. Once it exit, we should ignor that error returned by remove_task
|
||||
// to let it go.
|
||||
if let Err(error) = self.cgroup_manager.remove_task(cg_pid) {
|
||||
match error.source() {
|
||||
Some(err) => match err.downcast_ref::<io::Error>() {
|
||||
Some(e) => {
|
||||
if e.raw_os_error() != Some(OS_ERROR_NO_SUCH_PROCESS) {
|
||||
return Err(error.into());
|
||||
}
|
||||
}
|
||||
None => return Err(error.into()),
|
||||
},
|
||||
None => return Err(error.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.cgroup_manager
|
||||
|
Loading…
Reference in New Issue
Block a user