Skip to content

fix(microvm): honour the status filter in list_instances - #202

Merged
Shine-neko merged 1 commit into
mainfrom
fix/microvm-list-instances-status
Jul 25, 2026
Merged

fix(microvm): honour the status filter in list_instances#202
Shine-neko merged 1 commit into
mainfrom
fix/microvm-list-instances-status

Conversation

@Shine-neko

Copy link
Copy Markdown
Contributor

RuntimeLifecycle::list_instances takes a status filter that both microVM runtimes ignored: Cloud Hypervisor always scanned for Running, Firecracker returned every instance with a socket on disk — including the stale sockets a crashed VM leaves behind, which then looked like running instances.

Both now honour it, using the vocabulary the trait's callers already speak (Docker's): all accepts everything, active means running-or-coming-up, anything else is an exact state match.

  • Cloud Hypervisor maps the filter onto VM states. active resolves to the same trio the runtime already treats as "alive or about to be" when scaling and when running a job. This is deliberately wider than Docker's active, which excludes created: a CH VM sits in Created between spawn and boot, and dropping it there would make a freshly-started replica briefly invisible. all skips the per-instance API round trip entirely.
  • Firecracker has no VM-state API, so the only observable distinction is whether a live process still backs the instance — active and running collapse onto that, exited is its negation. Liveness is resolved with a single /proc pass per listing rather than one per instance, and keyed on the full socket path: two servers with different socket_dirs can mint the same instance id, and matching on the basename alone would let one mark the other's stale socket as live.

An unrecognised filter matches nothing on both runtimes. Falling back to "everything" would misreport a deployment as fully up.

One caller had to change with it. The rolling update refreshed the parent's instance list with active, which now correctly excludes dead instances — and that would have been a regression: the drain is what releases each instance's host resources (tap, rootfs copy, console logs, temp volumes), and a dead-but-not-reaped instance still holds all of them. An exhausted parent would have looked empty and been marked deleted without ever calling remove_instance. It now asks for all. This also fixes the symmetric leak on Docker, where an exited container was never reaped by the rolling update either.

Tests

779 unit tests pass (8 new); cargo fmt and cargo clippy --all-targets are clean. The new tests cover both filter mappings, the unknown-filter case, and the exact-path matching the liveness index relies on. The listing paths themselves need running VMs and are only exercised by the e2e suites, which do not run in CI.

@Shine-neko
Shine-neko merged commit 9f46b4a into main Jul 25, 2026
5 checks passed
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