runtime-rs: cleanup kata host share path

cleanup the /run/kata-containers/shared/sandboxes/pid path

Fixes:#5975
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
This commit is contained in:
Zhongtao Hu
2023-01-16 11:18:57 +08:00
parent 20196048bf
commit 2dd2421ad0
8 changed files with 58 additions and 23 deletions

View File

@@ -11,7 +11,7 @@ use async_trait::async_trait;
pub trait Sandbox: Send + Sync {
async fn start(&self, netns: Option<String>) -> Result<()>;
async fn stop(&self) -> Result<()>;
async fn cleanup(&self, container_id: &str) -> Result<()>;
async fn cleanup(&self) -> Result<()>;
async fn shutdown(&self) -> Result<()>;
// agent function

View File

@@ -174,7 +174,7 @@ impl RuntimeHandlerManager {
.await
.context("failed to restore the sandbox")?;
sandbox
.cleanup(&inner.id)
.cleanup()
.await
.context("failed to cleanup the resource")?;
}

View File

@@ -242,17 +242,7 @@ impl Sandbox for VirtSandbox {
self.stop().await.context("stop")?;
info!(sl!(), "delete cgroup");
self.resource_manager
.delete_cgroups()
.await
.context("delete cgroups")?;
info!(sl!(), "delete hypervisor");
self.hypervisor
.cleanup()
.await
.context("delete hypervisor")?;
self.cleanup().await.context("do the clean up")?;
info!(sl!(), "stop monitor");
self.monitor.stop().await;
@@ -269,9 +259,19 @@ impl Sandbox for VirtSandbox {
Ok(())
}
async fn cleanup(&self, _id: &str) -> Result<()> {
self.resource_manager.delete_cgroups().await?;
self.hypervisor.cleanup().await?;
async fn cleanup(&self) -> Result<()> {
info!(sl!(), "delete hypervisor");
self.hypervisor
.cleanup()
.await
.context("delete hypervisor")?;
info!(sl!(), "resource clean up");
self.resource_manager
.cleanup()
.await
.context("resource clean up")?;
// TODO: cleanup other snadbox resource
Ok(())
}