Repository navigation
fix(vmpool,microvm-worker): wait for swept VMMs before the startup probe; report a cgroup that doesn't empty - #798
Conversation
… not SweepOrphans SIGKILLs every pid in a leftover VM cgroup and then waited through waitForCgroupEmpty, which gives up after 200 ms without saying so, and the cgroup was counted as swept either way. A Firecracker VMM does not leave its cgroup the moment it is killed: the kernel first tears down its guest memory and descriptors, the API socket among them. On a KVM host the sweep reported "swept 1" while the killed VMM still answered on vm-1's API socket, and the startup probe that followed was refused by the launcher's collision guard. sweepOneCgroup now waits up to sweepExitWait (5 s, a variable so tests can shorten it) for the signalled processes to exit. A cgroup whose processes are still running when the wait ends is logged, left in place and reported in the new SweepResult.Stuck, instead of being counted in Swept; the sweep carries on with the other directories rather than failing on its rmdir. The wait is a separate helper: waitForCgroupEmpty's other caller, Destroy, has already reaped its VMM, so its short bound is unchanged. A listed pid counts while it is still running (kill(pid, 0)), which on cgroupfs is the same as being listed, and lets the synthetic cgroup tree the tests build, where cgroup.procs never changes, reach "emptied". Refs rossoctl#797 Signed-off-by: Rong Chang <[email protected]>
… before the probe After the orphan sweep, the worker went straight to pool.Probe, whose first Restore uses vm-1. A VMM the sweep had just SIGKILLed could still be answering on that id's API socket while the kernel tore it down, so the launcher's collision guard refused the restore and the worker exited; the next start, with the old VMM gone, succeeded. Recovery relied on systemd's Restart=on-failure. vmpool.WaitForHeldJails asks every jail under the Firecracker launcher's chroot tree whether a live VMM still answers on its API socket, using the same fcJailOccupied check Restore's collision guard makes, and waits (bounded) until none does. Every jail is asked, not only the swept ones, because a Firecracker VM's cgroup is a pooled pool-<n> that does not name its VM id; before Probe this worker has started no VM, so any listener in its tree was left by an earlier one. Other launchers have no jails and return at once. microvm-worker's new settleSweep runs it after a sweep that removed anything, with a 5 s bound. A socket still held at the end, or a cgroup the sweep reported as stuck, fails the start with a line naming the VM ids or cgroups, instead of the probe colliding with them. A stuck cgroup fails the start because the pool reuses cgroup names from pool-0 on every start, so the probe's VM would join the cgroup that still holds the old process. Refs rossoctl#797 Signed-off-by: Rong Chang <[email protected]>
On a KVM host, a worker start whose probe failed with "API socket never appeared" was followed by a start whose sweep reported one VM cgroup, which read as the failed probe having left a VM behind. Reading the code, every failure path already tears down: Restore's cleanup kills the jailer's process group and waits for it on the socket-wait failure (and on every later one), and once a VM exists Probe's deferred Destroy runs on the resume, guest and exit-code failures. The sweep's count does not show a live process either: it counts directories, and the pooled cgroup a failed restore returns is left on disk when the worker exits. So this adds no code, only tests that pin the teardown: one per Probe failure path after a VM exists, through the fake launcher, and one driving the real Firecracker Restore with a fake jailer that stays alive and never binds its API socket, asserting the process is gone when Restore returns. Refs rossoctl#797 Signed-off-by: Rong Chang <[email protected]>
…it waits WaitForHeldJails now logs, once it returns, how long it waited and which VM ids held their sockets when it began (and any still held), but only when it actually waited, so a later occurrence shows in the journal. Refs rossoctl#797 Signed-off-by: Rong Chang <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
After the orphan sweep kills an earlier incarnation's VMMs, the sweep now waits up to 5 s per cgroup for them to exit and reports a cgroup that doesn't empty as Stuck, which fails the start. Before the probe, the worker also waits up to 5 s for every pool-shaped Firecracker jail's API socket to lose its listener. I found nothing blocking. The control flow, the sweepOutcome plumbing, the Windows stub and the tests all hold up. pool.New starts no VMs before Probe, so there's no wider window for the jail scan to race against. I left two suggestions and a nit inline: the Swept == 0 gate skips the jail check in the one case the PR body can't explain, the per-cgroup wait serializes VMM teardowns, and the stuck-cgroup message should mention the start limit.
Author: webchang (MEMBER — maintainer)
Areas reviewed: Go (vmpool sweep, Firecracker launcher, microvm-worker startup), tests, systemd unit interaction
Agent/IDE config (.claude/.vscode): none
Commits: 4 commits, all signed-off: yes
CI status: passing (all 17 checks, incl. microvm-gates and k8s-kind-e2e)
AI-assisted review, approved by a maintainer before posting.
| return fmt.Errorf("orphan sweep: VM cgroup(s) %v still hold a process that has not exited after SIGKILL; "+ | ||
| "refusing to start beside it", res.Stuck) | ||
| } | ||
| if res.Swept == 0 { |
There was a problem hiding this comment.
suggestion: This gate skips the jail check in the case the PR body leaves unexplained. That's a live listener from a VMM outside the swept directories, i.e. one in another cgroup or one the jailer hadn't relocated yet. If no pool cgroup directory was left behind, Swept is 0 and the probe meets that listener in Restore's collision guard, which is the #797 failure. The body says the check costs one ReadDir plus one failed dial per jail when nothing is listening, so running heldJails unconditionally (and keeping the Stuck check first) costs almost nothing and closes that gap. The asked assertion in TestSettleSweepWaitsForHeldJailsBeforeTheProbe would flip to match.
| } | ||
| waitForCgroupEmpty(dir) | ||
| return true, removeCgroupDir(dir) | ||
| if running := waitForSweptPidsToExit(dir, sweepExitWait); len(running) > 0 { |
There was a problem hiding this comment.
suggestion: SweepOrphans calls this once per directory, and each call SIGKILLs and then waits up to sweepExitWait before the next cgroup gets its signal. After a crash with many VMs, the guests' memory teardowns (the comment above says they grow with guest RAM) run one after another instead of overlapping, and with N stuck cgroups the start takes N × 5 s before it fails. A two-pass shape would bound the whole sweep by one sweepExitWait: run guard 3 and the kills for every directory, then wait and rmdir. It keeps the same outcomes. Not blocking, since today's pools are small.
| func settleSweep(res vmpool.SweepResult, heldJails func(time.Duration) []string) error { | ||
| if len(res.Stuck) > 0 { | ||
| return fmt.Errorf("orphan sweep: VM cgroup(s) %v still hold a process that has not exited after SIGKILL; "+ | ||
| "refusing to start beside it", res.Stuck) |
There was a problem hiding this comment.
nit: In microvm-worker.service, Restart=on-failure/RestartSec=5s with StartLimitBurst=5 over StartLimitIntervalSec=300 means a cgroup that really is stuck (D-state) fails 5 starts in about 50 s. The unit then stays failed until someone runs systemctl reset-failed. That's probably right, but the PR body's "systemd's restart retries the start" undersells it. The message could name the stuck cgroup's path under the slice, so the operator knows where to look (cat …/cgroup.procs, /proc/<pid>/stack).
clawgenti
left a comment
There was a problem hiding this comment.
No must-fix findings. The sweep's new swept/refused/stuck result, the 5 s exit wait and WaitForHeldJails all reuse fcJailOccupied, so "held" means the same thing to the wait as to Restore's collision guard. The Windows stubs still build.
One suggestion is inline: when SweepOrphans returns an error, the new settle step is skipped, so the case this PR closes can still reach Probe.
- Author: webchang (MEMBER — maintainer)
- Areas reviewed: Go (
internal/vmpoolsweep and Firecracker launcher,cmd/microvm-workerstartup), tests - Agent/IDE config (.claude/.vscode): none
- Commits: 4 commits, all signed-off: yes
- CI status: passing (all 17 checks green, including k8s-kind-e2e and microvm-gates). Mergeable (
CLEAN).
Verified by:
gofmt -lclean.go vet ./internal/vmpool/ ./cmd/microvm-worker/clean.GOOS=windows go build ./internal/vmpool/buildsgo test -race -count=3 -run 'Sweep|HeldJail|settleSweep|Probe'over./internal/vmpool/and./cmd/microvm-worker/: pass. The fullgo test -racepasses exceptTestRestoreFoldsCloudHypervisorsOwnLogIntoTimeoutError, which fails the same way onmainin this sandbox (its fake virtiofsd can't exec here), so it is an environment failure and not caused by this PR- read
removeCgroupDirand theSweepOrphanserror path inmain.goto confirm the gap in the inline suggestion
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| } else { | ||
| log.Printf("microvm-worker: orphan sweep: swept %d VM cgroup(s) from a previous incarnation; left alone %d non-VM cgroup(s) %v", | ||
| res.Swept, len(res.Skipped), res.Skipped) | ||
| if err := settleSweep(res, func(d time.Duration) []string { return vmpool.WaitForHeldJails(lc, d) }); err != nil { |
There was a problem hiding this comment.
suggestion: settleSweep runs only in the else branch, so it is skipped when SweepOrphans returns an error (the err != nil branch at line 835 only logs it). That error can come after the sweep has already SIGKILLed VMMs. For example, waitForSweptPidsToExit returns nil when cgroup.procs can't be read, and its own comment leaves it to removeCgroupDir's rmdir to surface a cgroup that didn't empty. That rmdir failure then aborts SweepOrphans with return res, err, and the worker goes on to Probe with no jail wait and no stuck check. That is the collision #797 is about.
Suggested fix: settle on the partial result too, or fail the start:
} else if res, err := vmpool.SweepOrphans(sweepPath); err != nil {
log.Printf("microvm-worker: orphan sweep: %v", err)
if err := settleSweep(res, func(d time.Duration) []string { return vmpool.WaitForHeldJails(lc, d) }); err != nil {
log.Fatalf("microvm-worker: %v", err)
}
} else {(Or factor the call out below the if/else when the sweep ran at all.) Note that res.Swept may be 0 at that point even though a kill happened, so gate the held-jail wait on "the sweep ran" rather than on Swept > 0 in this path.
…te lifecycle stack Upstream main 0dc3d01 (API 1.21.0) carries the reviewed, final form of the features this branch held in early, integrated versions, through the PRs filed from this fork (rossoctl#755-rossoctl#776, rossoctl#781, rossoctl#782, rossoctl#784-rossoctl#786, rossoctl#789-rossoctl#794, rossoctl#798-rossoctl#800) and the maintainer's lease mode, grants and lease clients (rossoctl#763, rossoctl#802, rossoctl#807, rossoctl#808, rossoctl#810, rossoctl#812, rossoctl#814). Where upstream has a feature, upstream's version wins: its code, tests, openapi, CHANGELOG (byte identical), docs and specs. The fork was 736 commits behind and 390 ahead (merge base dd0ce71). Conflict resolution (148 files, 82 both-modified, 66 both-added): every conflicted file is upstream's side as is (byte identical to 0dc3d01). No conflicted file differs from 0dc3d01 in this commit. One file merged without a conflict and was set back to upstream's: - packages/mocactl/src/sbx/push.ts: the auto-merge added the fork's baselineAtHead a second time beside upstream's own (fb28e06's function, already upstream); upstream's file as is. With that, this commit's tree is 0dc3d01's plus the 18 files only the fork has (below). Every other file the fork changed is upstream's. Conflicted files, all resolved to upstream's side (0dc3d01): - deploy/k8s/overlays/ocp-combined/kustomization.yaml (AA) - deploy/k8s/overlays/ocp-combined/patch-addressing.yaml (AA) - deploy/k8s/overlays/ocp-combined/patch-relay.yaml (AA) - deploy/microvm/P4-ON-P6.md (UU) - deploy/microvm/build-rootfs.sh (UU) - deploy/microvm/build-snapshot.sh (UU) - deploy/microvm/setup-microvm.sh (UU) - deploy/microvm/tests/build-rootfs.test.sh (UU) - deploy/microvm/tests/build-snapshot.test.sh (UU) - deploy/microvm/tests/setup-microvm.test.sh (UU) - deploy/sbx/README.md (UU) - deploy/sbx/RUNBOOK.md (UU) - deploy/sbx/host-agent.sh (AA) - deploy/sbx/install-host.sh (UU) - deploy/sbx/sbx-host-agent-wanted.service (AA) - deploy/sbx/sbx-host-agent-wanted.timer (AA) - deploy/sbx/sbx-host-agent.service (AA) - deploy/sbx/[email protected] (UU) - deploy/sbx/setup.sh (UU) - deploy/sbx/template-onboarding/GUIDE.md (AA) - deploy/sbx/template-onboarding/ONBOARDING.md (AA) - deploy/sbx/template-onboarding/README.md (AA) - deploy/sbx/template-onboarding/examples/django__django-11133.gate-record.json (AA) - deploy/sbx/template-onboarding/examples/django__django-11133.json (AA) - deploy/sbx/template-onboarding/governance/GATING-RULES.md (AA) - deploy/sbx/template-onboarding/governance/PROCESS.md (AA) - deploy/sbx/template-onboarding/governance/README.md (AA) - deploy/sbx/template-onboarding/template-build.sh (AA) - deploy/sbx/template-onboarding/template-register.sh (AA) - deploy/sbx/template-onboarding/tests/examples.test.sh (AA) - deploy/sbx/template-onboarding/tests/template-build.test.sh (AA) - deploy/sbx/template-onboarding/tests/template-register.test.sh (AA) - deploy/sbx/template-onboarding/verify-provenance.py (AA) - deploy/sbx/templates-check.sh (AA) - deploy/sbx/tests/host-agent.test.sh (AA) - deploy/sbx/tests/install-host.test.sh (UU) - deploy/sbx/tests/overlay-combined.test.sh (AA) - deploy/sbx/tests/setup.test.sh (UU) - deploy/sbx/tests/templates-check.test.sh (AA) - deploy/vm/tests/setup-vm.test.sh (UU) - docs/api/CHANGELOG.md (UU) - docs/api/harness-openapi.yaml (UU) - docs/api/openapi.yaml (UU) - docs/concepts/sandboxes-and-tiers.md (UU) - docs/reference/change-policy.md (UU) - docs/reference/cli-mocactl.md (UU) - docs/reference/configuration.md (UU) - docs/reference/http-api.md (UU) - docs/sbx/user-guide.md (UU) - docs/specs/2026-10-15-sbx0-internal-sandbox-service-design.md (UU) - docs/specs/2026-10-30-session-sandbox-templates-design.md (AA) - docs/specs/2026-11-03-template-lifecycle-and-provenance-design.md (AA) - docs/specs/2026-11-05-combined-control-plane-design.md (AA) - docs/specs/2026-11-08-enrollment-and-roles-api-design.md (AA) - docs/specs/2026-11-08-sandbox-egress-records-design.md (AA) - docs/specs/2026-11-08-subject-trust-gate-records-design.md (AA) - docs/specs/README.md (UU) - harness/src/run-turn.ts (UU) - harness/src/sandbox-affinity.ts (UU) - harness/src/select-sandbox.ts (UU) - harness/test/select-sandbox-templates.test.ts (AA) - harness/test/turn-seed.test.ts (AA) - harness/test/turn-stream.test.ts (UU) - packages/control-plane/src/activation-lock.ts (AA) - packages/control-plane/src/activation.ts (AA) - packages/control-plane/src/egress-handlers.ts (UU) - packages/control-plane/src/egress-log.ts (AA) - packages/control-plane/src/errors.ts (UU) - packages/control-plane/src/exchange.ts (UU) - packages/control-plane/src/handler-util.ts (UU) - packages/control-plane/src/handlers.ts (UU) - packages/control-plane/src/host-handlers.ts (AA) - packages/control-plane/src/identity.ts (UU) - packages/control-plane/src/index.ts (UU) - packages/control-plane/src/main.ts (UU) - packages/control-plane/src/member-handlers.ts (AA) - packages/control-plane/src/members.ts (AA) - packages/control-plane/src/ownership.ts (UU) - packages/control-plane/src/provenance.ts (AA) - packages/control-plane/src/routes.ts (UU) - packages/control-plane/src/sandbox-config.ts (UU) - packages/control-plane/src/sandbox-handlers.ts (UU) - packages/control-plane/src/server.ts (UU) - packages/control-plane/src/template-catalog.ts (AA) - packages/control-plane/src/template-policy.ts (AA) - packages/control-plane/src/token.ts (UU) - packages/control-plane/test/activation.test.ts (AA) - packages/control-plane/test/egress-redis.test.ts (AA) - packages/control-plane/test/errors.test.ts (UU) - packages/control-plane/test/host-flow.test.ts (AA) - packages/control-plane/test/members.test.ts (AA) - packages/control-plane/test/openapi-contract.test.ts (UU) - packages/control-plane/test/provenance.test.ts (AA) - packages/control-plane/test/repository-allowlist.test.ts (AA) - packages/control-plane/test/route-authz-enumeration.test.ts (UU) - packages/control-plane/test/route-profile.test.ts (UU) - packages/control-plane/test/routes.test.ts (UU) - packages/control-plane/test/sandbox-egress.test.ts (AA) - packages/control-plane/test/sandbox-handlers.test.ts (UU) - packages/control-plane/test/session-templates.test.ts (AA) - packages/control-plane/test/subject-trust.test.ts (AA) - packages/control-plane/test/template-admin.test.ts (AA) - packages/control-plane/test/template-catalog.test.ts (AA) - packages/control-plane/test/template-create.test.ts (AA) - packages/knative-server/src/server.ts (UU) - packages/knative-server/src/turn-auth.ts (UU) - packages/knative-server/test/turn-auth.test.ts (UU) - packages/mocactl/src/api/errors.ts (UU) - packages/mocactl/src/api/frames.ts (UU) - packages/mocactl/src/cli.ts (UU) - packages/mocactl/src/core/session-manager.ts (UU) - packages/mocactl/src/core/session-options.ts (UU) - packages/mocactl/src/headless.ts (UU) - packages/mocactl/src/sbx/api.ts (UU) - packages/mocactl/src/sbx/call-record.ts (AA) - packages/mocactl/src/sbx/cli.ts (UU) - packages/mocactl/src/sbx/commands.ts (UU) - packages/mocactl/src/sbx/dry-run.ts (AA) - packages/mocactl/src/sbx/exec.ts (UU) - packages/mocactl/src/sbx/run.ts (UU) - packages/mocactl/src/sbx/templates.ts (AA) - packages/mocactl/test/contract.test.ts (UU) - packages/mocactl/test/harness.test.ts (UU) - packages/mocactl/test/headless.test.ts (UU) - packages/mocactl/test/helpers/sbx.ts (UU) - packages/mocactl/test/run-record.test.ts (AA) - packages/mocactl/test/sbx-admin-subjects.test.ts (AA) - packages/mocactl/test/sbx-cli.test.ts (UU) - packages/mocactl/test/sbx-egress.test.ts (AA) - packages/mocactl/test/sbx-exec.test.ts (UU) - packages/mocactl/test/sbx-templates.test.ts (AA) - packages/mocactl/test/session-manager.test.ts (UU) - packages/mocactl/test/session-options.test.ts (UU) - remote-worker/cmd/microvm-worker/main.go (UU) - remote-worker/cmd/microvm-worker/template_record.go (AA) - remote-worker/cmd/microvm-worker/template_record_test.go (AA) - remote-worker/cmd/microvm-worker/verify_cache.go (AA) - remote-worker/cmd/microvm-worker/verify_cache_test.go (AA) - remote-worker/internal/egress/audit_test.go (UU) - remote-worker/internal/session/labels.go (UU) - remote-worker/internal/vmpool/errors.go (UU) - remote-worker/internal/vmpool/guestconn.go (UU) - remote-worker/internal/vmpool/guestconn_test.go (UU) - remote-worker/internal/vmpool/launcher_firecracker.go (UU) - remote-worker/internal/vmpool/launcher_firecracker_egress_unix_test.go (UU) - remote-worker/internal/vmpool/snapshot.go (UU) - remote-worker/internal/vmpool/snapshot_test.go (UU) - remote-worker/internal/vmpool/verifycache.go (AA) Fork-only files, kept as they are (upstream has no such file): - deploy/sbx/mint-login.sh, deploy/sbx/tests/mint-login.test.sh: a test login minted with the deployment's signing key. Checked against upstream: makeSigner/mint, SANDBOX_API_ISSUER, the moca-mu1 Secret and its label, the env keys it reads and mocactl's sbx-auth.json shape are all still upstream's. - deploy/sbx/template-onboarding/deck/ (README, requirements, the two generators, deck_kit.py, the two PDFs, .gitignore): the fork's decks. - deploy/sbx/template-onboarding/GUIDE.pdf: regenerated from upstream's GUIDE.md in a later commit. - deploy/sbx/template-onboarding/governance/GAPS-AND-ASSUMPTIONS.md and INVENTORY-2026-11-02.md: the fork's register and inventory. - docs/specs/2026-11-09-cold-start-pacing-design.md, 2026-11-09-memory-aware-placement-design.md and 2026-11-10-mocactl-template-commands-design.md: the fork's design notes; upstream folded their content into its lifecycle spec (§6.4 memory, §6.5 pacing) and the user guide (mocactl). - docs/tools/gen_pdf.py, docs/tools/gen_toc.py: the PDF and TOC tools. Fork-only behaviour, decided one by one (from git log 0dc3d01..f125c02 --no-merges, checked against 0dc3d01): Ported onto upstream's code, each in its own commit after this one: - The pinned-session retire guard (c571226): a retire is refused (409 build_in_use) while an active Moca Pi session is pinned to the build. Upstream's buildsInUse checks live sandboxes only and its comment says pinned sessions are still to be checked. - Reuse only while a host holds the snapshot (G29, 521efe5): upstream reuses any registered build with the same inputs; its own lifecycle spec (§4, Reuse) says a registered build is reused only while a host reports holding its snapshot. - install-host.sh --uninstall-shared and the mounted legacy jail guard (5e66397): upstream has neither. - GUIDE §4b.4's base example without skip_git_identity_check (f125c02): upstream applies X12 under every profile, so its example create would be refused. - Links from upstream's READMEs to the fork-only files above. Dropped, because upstream's design replaces them on purpose: - Removal of admin-rejected builds: upstream stops them and never removes them (the user's decision in rossoctl#786). - The harness-profile catalog's fallback to SH_SESSION_TEMPLATES (902255b): upstream serves the harness profile the store's templates only (its test was renamed so); a combined plane is unaffected. - The fork's register ids (G-numbers), window dates and results pointers inside the documents upstream now has (RUNBOOK, README, GUIDE, ONBOARDING, PROCESS, GATING-RULES, P4-ON-P6, the specs): upstream's text wins; the fork's own documents above keep them. - The fork's image-builder-specific wording in GATING-RULES.md: upstream's generic wording (the image builder) is taken as is. Dropped, could be re-proposed (no upstream equivalent, but the port is an API change or its intent upstream is unclear): - TurnPlacement.template, a turn result naming the session's sandbox template (9d6004d): a harness API field; upstream's CHANGELOG is kept byte identical. - An imported build's catalog entry and create record carrying the declared seed (20d0995): sessions are seeded the same (upstream falls back to the declared seed); only the field in the catalog API goes. - mocactl: sbx create --seed checking the seeded HEAD against the spec's baseline_commit; activate --wait stopping at once on not_held or memfile_mismatch; ApiError's readiness, readinessReason and queuePosition in refusals; an admin write refused when the control plane URL came only from the login; the admin-write issuer check for the combined profile; the dry run's X1.offline check and its guest_mb and git-less advice; the quota, policy and build lines' extra fields (quotaSource, selfAttest, allowedRepositories, heldBy, attestation). Upstream's reviewed client (rossoctl#767, rossoctl#768) left them out; the server still enforces every rule. Already upstream (not lost): build reuse (G21), the verify cache, the host agent's --keep-shared removals, read-ahead, the hash_version 2 check in the microVM worker, M7, G39, G42, G43, G48, G49, G50, mocactl --record, --version, the minted login's own control plane, activate --wait sizing, and every other fork feature listed in the task. The relay's per-client tokens: not on this branch (the fork's sandbox-relay main.ts is older upstream code), so nothing to resolve. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Closes #797. Four signed-off commits on main (86d6350), in
remote-workeronly.What it does: after the orphan sweep kills a previous incarnation's VMMs, the worker waits for them to exit and to release their API sockets before its startup probe. A cgroup that won't empty is reported, not counted as swept.
sweepOneCgroupwaits up todefaultSweepExitWait(5 s) for the killed processes to exit, where it used to give up after about 200 ms and count the cgroup as swept anyway;Swept, and listed in a newSweepResult.Stuck, and the sweep goes on with the other directories;waitForCgroupEmptyandDestroyare unchanged: Destroy has already reaped its VMM, so it isn't the same case.vmpool.WaitForHeldJailsreuses the launcher's collision check (fcJailOccupied), through an optional interface that only the Firecracker launcher implements. Cloud Hypervisor returns at once;settleSweepinmain.go: if any cgroup is stuck, the start fails, naming it. Otherwise, after a sweep that removed anything, it waits up to 5 s for every pool-shaped jail's API socket to have no listener. A socket still held fails the start, naming the VM ids.Destroycovers the rest). These tests pin that.A behavior change: a worker now refuses to start while a swept cgroup still holds a process that SIGKILL hasn't ended. The pool reuses cgroup names from
pool-0, so going on would put the probe's VM beside the unkilled VMM. systemd's restart retries the start.Notes for review:
Sweptcounts directories, and a pooled cgroup stays on disk when the worker exits.Swept > 0, not only when something was killed, becauseSweptcan't tell those apart. With no listener it costs one directory read and one failed dial per jail.WaitForHeldJailschecks every pool-shaped jail, so it covers that either way.Tests:
gofmt -landgo vet ./...are clean;go test -racepasses for./internal/vmpool/...and./cmd/microvm-worker/..., andgo test ./...passes;Stuck, uncounted, with its directory kept, while an empty sibling is still swept;Assisted-By: Claude Code