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 <alex.lyn@antgroup.com>
This commit is contained in:
Alex Lyn
2026-04-30 16:50:26 +08:00
parent c26aecd173
commit 610f538c8e

View File

@@ -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]