shim: don't tear down shared pod UVM on Hyper-V container restart #2846
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 337 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.348
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2846"
general
weight: 0.35
rzlink
Description
Fix in-place container restarts for Hyper-V isolated Windows pods (
runhcs-wcow-hypervisor), e.g. withContainerRestartRules/RestartAllContainers. Today a workload container restart can tear down the shared pod UVM, killing the sandbox and every other container in the pod. This is the failure reported in kubernetes/kubernetes#140187.Root cause
A Windows guest holds the
WaitForProcessresponse of a process until the host closes the process's stdio relay. A descendant process (for example the child ofsh -c "...; sleep ...") can keep the relay open after the process itself has exited, while the host only closes the relay once the wait completes, so neither side makes progress. The SIGKILL that follows returnshrNotFound, which was logged and ignored, leaving the wait pending. The 30s SIGKILL watchdog inKillExecthen closed the UVM, even when the task did not own it.Fix
1. Gate the
KillExecSIGKILL watchdog onownsHost, so only a task that owns its UVM can close it. A workload container shares the pod UVM.2. When a Windows guest reports a process missing while its wait is still pending, wait a grace period for the real exit, then close the host side of the process's stdio relay. The guest then delivers the real exit code; no exit is synthesized and the bridge protocol is unchanged. The grace period (1s) matches the default
CopyAfterExitTimeoutthe host already allows stdio relays after a process exits, and the path is only taken on the abnormalhrNotFoundpath.Linux guests (LCOW) are excluded: they drain and close the relay themselves before answering the wait, and reconnect if the host closes it first. Process-isolated containers don't use this code path.
Testing
go test ./internal/gcs ./cmd/containerd-shim-runhcs-v1, including new tests that:- the real exit code is kept and stdio stays open when the real exit arrives within the grace period;
- stdio is closed to release the real exit when the guest holds it;
- a Linux guest's stdio relay is never closed.
RestartAllContainerse2e specs that fail today 10 times each: 40/40 passed (0/4 before). With ETW (ContainerPlatform) traces: no watchdog, no UVM close/terminate during the tests; everyhrNotFoundwas followed by the stdio close after ~1s and the real exit (0xC000013A) within a few ms, which containerd reported as the container's exit status.sh -cwith a child,sh -cwith redirect /exec, direct process, grace 0/2): sandbox and sibling containers stayed running and the UVM was not closed in every case; real exit codes were reported.