Skip to content

fix(microvm-worker): the orphan sweep's log says how many swept cgroups held a live VM - #849

Merged
webchang merged 1 commit into
rossoctl:mainfrom
webchang:pr/sync-orphan-sweep-count
Nov 17, 2026
Merged

webchang merged 1 commit into
rossoctl:mainfrom
webchang:pr/sync-orphan-sweep-count

Conversation

@webchang

Copy link
Copy Markdown
Member

microvm-worker: the orphan sweep's startup line now tells a killed VM apart from an empty cgroup directory.

What changed and why

  • The startup line orphan sweep: swept N VM cgroup(s) from a previous incarnation counts cgroup directories removed (SweepResult.Swept). A VM process still running that the sweep had to SIGKILL, and an empty pool directory a clean shutdown left behind, each count as one, so an operator reading the log cannot tell a leaked VM from housekeeping.
  • SweepResult gains Killed: the swept directories whose cgroup.procs listed at least one process still running (pidStillRunning) when the sweep signalled it. sweepOneCgroup reports such a directory with a new outcome, cgroupSweptLive.
  • SweepResult.Summary() formats the line, and cmd/microvm-worker logs it:
    orphan sweep: swept N VM cgroup(s) from a previous incarnation: K held a live process (killed), M were empty; left alone S non-VM cgroup(s) [...]
  • Nothing else changes. The sweep signals, waits for and removes exactly what it did before. Swept keeps its meaning (it still counts both kinds), so settleSweep's decision to wait for held jails is unchanged. A pid that exits on its own between the liveness check and the signal is counted as killed, the safe side for a line meant to say a VM may have been alive.
  • The sweep only works on cgroup directories: it does not kill processes by name or remove sockets or VM directories elsewhere, so there is nothing else to count.

Tests

  • New: TestSweepOrphansSummaryTellsAKilledVMFromAnEmptyDirectory (remote-worker/internal/vmpool/cgroup_test.go). A fake slice holds vm-12 with a real live child process, pool-0 with an empty cgroup.procs, and vm-13 listing the pid of a child that has already exited. It asserts the live child is reaped, Swept = 3, Killed = 1, and the exact Summary() line (1 held a live process (killed), 2 were empty).
    • On main (source files reverted, new test kept): build fails, res.Killed undefined / res.Summary undefined; main has no way to report the split.
    • With the liveness count disabled (mutation: live never set): Swept = 3, Killed = 0; want 3 swept, 1 of them holding a live process, FAIL.
    • With the fix: PASS.
  • go vet ./..., GOOS=linux go vet ./..., GOOS=linux go test -c for internal/vmpool and cmd/microvm-worker, and GOOS=windows go build ./internal/vmpool: clean.
  • go test -race -count=1 ./internal/vmpool ./cmd/microvm-worker: ok. go test -count=1 ./... in remote-worker: ok.

Every commit is signed off (DCO).

Assisted-By: Claude Code

The orphan sweep's startup line, "swept N VM cgroup(s) from a previous
incarnation", counts cgroup directories removed. A VM process that was
still running and had to be SIGKILLed and an empty pool directory left
by a clean shutdown each add one, so an operator cannot tell a leaked VM
from housekeeping.

SweepResult gains Killed, the swept directories whose cgroup.procs listed
a process still running when it was signalled, and a Summary method the
worker now logs:

  swept N VM cgroup(s) from a previous incarnation: K held a live
  process (killed), M were empty; left alone S non-VM cgroup(s) [...]

What the sweep signals, waits for and removes is unchanged; Swept keeps
its meaning, so settleSweep's decision is unchanged too.

Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>
@webchang
webchang requested a review from pdettori as a code owner November 17, 2026 14:35
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 17, 2026
@pdettori pdettori added this to the v0.11.0 milestone Nov 17, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

SweepResult gains Killed, set by the new cgroupSweptLive outcome when some pid in a swept directory passed pidStillRunning (kill -0, or EPERM) just before its SIGKILL. The startup log goes through SweepResult.Summary(). Signal, wait and rmdir behavior are unchanged, and Swept keeps counting both kinds, so settleSweep (which reads only Swept/Stuck) is unaffected. The Windows stub returns false, which is fine for a log-only count. The new test covers live, empty and already-exited directories. No issues found.

Author: webchang (MEMBER — maintainer)
Areas reviewed: Go (remote-worker vmpool, microvm-worker)
Agent/IDE config (.claude/.vscode): none
Commits: 1, all signed-off: yes
CI status: all green (17 checks)

@webchang
webchang merged commit 991239f into rossoctl:main Nov 17, 2026
23 of 24 checks passed
webchang added a commit to webchang/moca that referenced this pull request Nov 18, 2026
Brings 25 upstream merges since 1aa8dd6, among them the sbx OIDC
identity provider (rossoctl#851), the Redis schema-version key and config
bundle format marker (rossoctl#868), the provisioner Redis ACL user (rossoctl#869),
the relay keepalive env (rossoctl#866), the per-source OIDC pending bound with
the forwarded-headers Route pin (rossoctl#874), the egress refusal hints and
control-plane index (rossoctl#864), the empty-workspace sweep (rossoctl#872) and the
orphan-sweep log split (rossoctl#849). No conflicts.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants