From 3358c7634b2f564cf4465b602fc7095623e05b62 Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Thu, 30 Apr 2026 16:50:26 +0800 Subject: [PATCH] runtime-rs: Avoid shutting down sandbox on container exit Prevent the sandbox from being prematurely shut down when a standard workload container exits. Previously, the shutdown logic incorrectly triggered a sandbox shutdown whenever the container list became empty. This resulted in unintended lifecycle termination for non-transient sandboxes. This change refines the `need_shutdown_sandbox()` criteria in `virt_container/src/container_manager/manager.rs` to only initiate a shutdown under specific conditions: - The shutdown request is explicit (`req.is_now`). - The request targets the sandbox itself (`req.container_id == self.sid`). By removing the implicit dependency on the empty container list, we ensure the sandbox remains active as expected after workload containers finish execution. Signed-off-by: Alex Lyn --- .../runtimes/virt_container/src/container_manager/manager.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/manager.rs b/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/manager.rs index 43d2ce8df8..fe0ff2a82c 100644 --- a/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/manager.rs +++ b/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/manager.rs @@ -460,7 +460,7 @@ impl ContainerManager for VirtContainerManager { #[instrument] async fn need_shutdown_sandbox(&self, req: &ShutdownRequest) -> bool { - req.is_now || self.containers.read().await.is_empty() || self.sid == req.container_id + req.is_now || self.sid == req.container_id } #[instrument]