mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-01 05:04:26 +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::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
iter::FromIterator,
|
iter::FromIterator,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
@ -24,6 +26,8 @@ use oci::LinuxResources;
|
|||||||
use persist::sandbox_persist::Persist;
|
use persist::sandbox_persist::Persist;
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
|
const OS_ERROR_NO_SUCH_PROCESS: i32 = 3;
|
||||||
|
|
||||||
pub struct CgroupArgs {
|
pub struct CgroupArgs {
|
||||||
pub sid: String,
|
pub sid: String,
|
||||||
pub config: TomlConfig,
|
pub config: TomlConfig,
|
||||||
@ -109,7 +113,22 @@ impl CgroupsResource {
|
|||||||
/// overhead_cgroup_manager to the parent and then delete the cgroups.
|
/// overhead_cgroup_manager to the parent and then delete the cgroups.
|
||||||
pub async fn delete(&self) -> Result<()> {
|
pub async fn delete(&self) -> Result<()> {
|
||||||
for cg_pid in self.cgroup_manager.tasks() {
|
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
|
self.cgroup_manager
|
||||||
|
Loading…
Reference in New Issue
Block a user