You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
microvm-worker: after the orphan sweep kills a VM, the startup probe can collide with it #797
At start, microvm-worker sweeps VM cgroups left under its slice (vmpool.SweepOrphans), then runs pool.Probe, which restores vm-1. sweepOneCgroup kills each pid and then waits for the cgroup to
empty, but waitForCgroupEmpty gives up after 200 ms without saying so, and the sweep then counts the
cgroup as swept.
Observed on a KVM host, starting a worker whose slice held one leaked VM:
"orphan sweep: swept 1", then at once "startup probe: could not restore a VM: firecracker: restore
vm-1: a live VMM already holds this VM id's API socket at …/vm-1", and exit 1;
after systemd's restart: "swept 0", then "API socket never appeared: timed out after 5s", and exit
1, leaving a VM of its own behind;
after a second restart: "swept 1", then the snapshot verified and pinned, and the worker attached.
So recovery relied on Restart=on-failure, cost two failed starts, and a failed probe itself leaked a
VM.
Proposal
sweepOneCgroup waits for the killed processes to exit for longer (bounded, a few seconds), and
reports a cgroup that did not empty as not swept, logging it, instead of counting it.
Before pool.Probe, the worker waits (bounded) for the swept VM ids' API sockets to have no
listener, the same check the launcher's collision test makes.
A failed probe tears down the VM it started before the worker exits.
What the PR will contain
remote-worker/internal/vmpool/cgroup.go (the wait and the report), remote-worker/cmd/microvm-worker
(the wait before the probe; the probe's teardown on failure), with tests for each.
Depends on
Nothing. Related: the worker-stop VM leak (separate issue), which is what leaves the orphan.
How to verify
go test ./remote-worker/internal/vmpool/... ./remote-worker/cmd/microvm-worker/...; on a KVM host,
start a worker whose slice holds a leaked VM: one start sweeps it and attaches.
Limits / out of scope
The waits are bounded; a VMM that does not exit within them still fails the start, now with a line
saying which.
Activity
fix(vmpool): log the pre-probe wait for swept VMMs' API sockets when …
fix(vmpool): wait for swept VMMs to exit, and report the ones that do…
fix(microvm-worker): wait for swept VMMs to release their API sockets…
test(vmpool): pin the startup probe's teardown on every failure path