Merge pull request #10043 from lifupan/fix_sandbox

runtime-rs : fix the issue of stop sandbox
This commit is contained in:
Fupan Li
2024-07-29 09:22:26 +08:00
committed by GitHub
2 changed files with 13 additions and 2 deletions

View File

@@ -275,6 +275,10 @@ impl ContainerInner {
signal: u32,
all: bool,
) -> Result<()> {
if self.check_state(vec![ProcessStatus::Stopped]).await.is_ok() {
return Ok(());
}
let mut process_id: agent::ContainerProcessID = process.clone().into();
if all {
// force signal init process

View File

@@ -471,8 +471,15 @@ impl Sandbox for VirtSandbox {
}
async fn stop(&self) -> Result<()> {
info!(sl!(), "begin stop sandbox");
self.hypervisor.stop_vm().await.context("stop vm")?;
let mut sandbox_inner = self.inner.write().await;
if sandbox_inner.state != SandboxState::Stopped {
info!(sl!(), "begin stop sandbox");
self.hypervisor.stop_vm().await.context("stop vm")?;
sandbox_inner.state = SandboxState::Stopped;
info!(sl!(), "sandbox stopped");
}
Ok(())
}