Skip to content

shim: don't tear down shared pod UVM on Hyper-V container restart - #2846

Open
rzlink wants to merge 1 commit into
microsoft:mainfrom
rzlink:fix-hyperv-shared-uvm-restart
Open

shim: don't tear down shared pod UVM on Hyper-V container restart#2846
rzlink wants to merge 1 commit into
microsoft:mainfrom
rzlink:fix-hyperv-shared-uvm-restart

Conversation

@rzlink

@rzlink rzlink commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Description

Fix in-place container restarts for Hyper-V-isolated Windows pods.

Two issues could combine to destroy the shared pod UVM:

  1. When SignalProcess returned hrNotFound while WaitForProcess remained pending, process shutdown could block indefinitely. Force-complete the pending wait and tolerate its possible late response.
  2. The SIGKILL watchdog could directly close the UVM from a workload task that did not own it. Gate the watchdog on ownsHost and use closeHost for teardown.

This prevents a workload container restart from terminating the sandbox and sibling containers sharing the UVM.

Testing

  • go test ./internal/gcs

On Hyper-V-isolated Windows pods (runhcs-wcow-hypervisor), in-place container
restarts (ContainerRestartRules / RestartAllContainersOnContainerExits) fail:
when a workload container exits it is not restarted in place; the pod ends up
Failed. Two hcsshim/GCS issues combine to destroy the shared pod UVM.

1. Under RestartAll churn the guest GCS delivers a container's WaitForProcess
   exit reply late (or drops it); a crossing SIGKILL then returns hrNotFound
   while the wait is still pending. Process.Signal only logged "ignoring
   missing process", so the wait never completed and container Stop blocked
   forever. Force-complete the pending wait on hrNotFound so Wait()/Stop can't
   hang, and make an unmatched late response in recvLoop non-fatal (log and
   continue) rather than tearing the bridge down.

2. The KillExec 30s SIGKILL-init watchdog closed ht.host directly with no
   ownsHost guard, so a non-owning workload container's stuck stop tore down
   the shared pod UVM, killing the sandbox and its siblings. Gate the watchdog
   on ht.ownsHost and route teardown through closeHost so only the UVM owner
   may close it.

Process-isolated pods are unaffected (host HCS exit path, no shared UVM).

Adds unit tests for bridge.forceComplete and the non-fatal unknown-rpc path.

Signed-off-by: Dawei Wei <wei.dawei.cn@gmail.com>
@rzlink
rzlink requested a review from a team as a code owner July 30, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant