Skip to content

fix(tart): notice a runner that dies inside a running VM - #102

Merged
ysya merged 4 commits into
mainfrom
fix/tart-runner-liveness
Dec 1, 2026
Merged

ysya merged 4 commits into
mainfrom
fix/tart-runner-liveness

Conversation

@ysya

@ysya ysya commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Third of four stacked PRs. Stacked on #101; merge that first.

Problem

A Tart VM keeps running when the runner inside it exits. WaitInstance only watched the VM's tart run process, and after a start nothing else checked the runner. A runner that died while idle stayed counted as an idle runner for good. On a macOS host, with its two VM slots, that silently took half of the capacity.

Docker has no such gap, because the runner is the container's main process.

This matters more once min-runners is the only way to keep a runner ready, which the next PR in this stack makes it.

Fix

WaitInstance now also checks the runner process (pgrep -f Runner.Listener through tart exec) every 20 seconds, and returns once three checks in a row found none.

  • One or two misses are tolerated, because the runner is briefly absent while it restarts to update itself.
  • A check that could not reach the guest counts as neither alive nor gone.
  • The VM is left running. The controller removes it, as it does for any instance that exited.

No new configuration.

Tests

In internal/provider/tart_liveness_test.go:

Test Before the fix
TestTartProvider_WaitInstanceReportsRunnerThatDied fails: WaitInstance never returns
TestTartProvider_WaitInstanceToleratesRunnerRestart fails if a single missed check is enough
TestTartProvider_WaitInstanceIgnoresChecksThatFailed guards the unreachable-guest case

TestTartIntegration_WaitInstanceReportsRunnerThatDied does the same against a real VM. On an Apple silicon host with tart 2.40.1, with the check interval set to 2 s: watching outlasted 15 s while the runner was alive, and the runner was reported gone 6.9 s after it was killed inside the guest, with the VM still running.

go test ./... -race, go vet ./... and golangci-lint run ./... pass.

Not verified

  • A real runner. The check assumes its process is named Runner.Listener and that a self-update keeps it absent for less than 40 seconds. Both were tested with a stand-in runner only.

ysya added 3 commits December 2, 2026 01:30
Tart can create the clone and still fail, for example when a cancelled
context kills the command. Nothing tracked that VM yet, so it stayed on
disk until the next start of runscaler removed it as an orphan. A warm pool
that was shut down while a worker was cloning its next VM left one behind
about one time in three.

A failed clone is now deleted, with a deadline. A clone refused by the
free-space floor never reached Tart, and one Tart refused because the name
is taken left a VM that belongs to someone else, so neither is deleted.
…eal VMs

The Tart tests answered every command from a mock inside the test process,
which cannot show what ends a `tart run` or whether anything waits for it.

A stand-in `tart` shell script now lets three tests run the provider
through os/exec. They run in CI on Linux and macOS and fail if a VM's
process dies with its start context, or if Shutdown returns before the
processes it killed are gone.

The `TestTartIntegration_` tests boot VMs with the real `tart` and skip
unless RUNSCALER_TEST_TART_IMAGE is set. No CI can run them, because Tart
needs Apple silicon and hosted Apple silicon runners cannot nest a VM.
scripts/prepare-tart-test-image.sh prepares their base image with a
stand-in for the Actions runner, so they register nothing with GitHub.
docs/development.md says when and how to run them.
A Tart VM keeps running when the runner inside it exits. WaitInstance only
watched the VM, so a runner that died while idle stayed counted as an idle
runner for good. On a macOS host, with its two VM slots, that silently took
half of the capacity. Docker has no such gap, because the runner is the
container's main process.

WaitInstance now also checks the runner process every 20 seconds and
returns once three checks in a row found none. One or two misses are
tolerated, since the runner is briefly absent while it restarts to update
itself, and a check that could not reach the guest counts as neither. The
VM is left running: the controller removes it, as it does for any instance
that exited.
Base automatically changed from test/tart-process-and-real-host to main December 1, 2026 19:31
@ysya
ysya merged commit 9f5928b into main Dec 1, 2026
11 checks passed
@ysya
ysya deleted the fix/tart-runner-liveness branch December 1, 2026 19:33
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