mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-01 05:04:26 +00:00
runtime-rs: ignore errors during clean up sandbox resources
Ignore errors during clean up sandbox resources as much as we can. Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
This commit is contained in:
parent
62e328ca5c
commit
b3901c46d6
@ -117,17 +117,18 @@ impl ServiceManager {
|
|||||||
pub async fn cleanup(sid: &str) -> Result<()> {
|
pub async fn cleanup(sid: &str) -> Result<()> {
|
||||||
let (sender, _receiver) = channel::<Message>(MESSAGE_BUFFER_SIZE);
|
let (sender, _receiver) = channel::<Message>(MESSAGE_BUFFER_SIZE);
|
||||||
let handler = RuntimeHandlerManager::new(sid, sender).context("new runtime handler")?;
|
let handler = RuntimeHandlerManager::new(sid, sender).context("new runtime handler")?;
|
||||||
handler.cleanup().await.context("runtime handler cleanup")?;
|
if let Err(e) = handler.cleanup().await {
|
||||||
let temp_dir = [KATA_PATH, sid].join("/");
|
warn!(sl!(), "failed to clean up runtime state, {}", e);
|
||||||
if std::fs::metadata(temp_dir.as_str()).is_ok() {
|
|
||||||
// try to remove dir and skip the result
|
|
||||||
fs::remove_dir_all(temp_dir)
|
|
||||||
.map_err(|err| {
|
|
||||||
warn!(sl!(), "failed to clean up sandbox tmp dir");
|
|
||||||
err
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let temp_dir = [KATA_PATH, sid].join("/");
|
||||||
|
if fs::metadata(temp_dir.as_str()).is_ok() {
|
||||||
|
// try to remove dir and skip the result
|
||||||
|
if let Err(e) = fs::remove_dir_all(temp_dir) {
|
||||||
|
warn!(sl!(), "failed to clean up sandbox tmp dir, {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user