mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-17 22:34:25 +01:00
runtime-rs: support the functionality of cleanup
Cleanup sandbox resource Fixes: #4891 Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
This commit is contained in:
@@ -26,7 +26,6 @@ use tokio::{
|
||||
use ttrpc::asynchronous::Server;
|
||||
|
||||
use crate::task_service::TaskService;
|
||||
|
||||
/// message buffer size
|
||||
const MESSAGE_BUFFER_SIZE: usize = 8;
|
||||
use persist::KATA_PATH;
|
||||
@@ -151,7 +150,12 @@ impl ServiceManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cleanup(sid: &str) -> Result<()> {
|
||||
pub async fn cleanup(sid: &str) -> Result<()> {
|
||||
let (sender, _receiver) = channel::<Message>(MESSAGE_BUFFER_SIZE);
|
||||
let handler = RuntimeHandlerManager::new(sid, sender)
|
||||
.await
|
||||
.context("new runtime handler")?;
|
||||
handler.cleanup().await?;
|
||||
let temp_dir = [KATA_PATH, sid].join("/");
|
||||
if std::fs::metadata(temp_dir.as_str()).is_ok() {
|
||||
// try to remove dir and skip the result
|
||||
|
||||
Reference in New Issue
Block a user