Repository navigation
fix(tart): notice a runner that dies inside a running VM - #102
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third of four stacked PRs. Stacked on #101; merge that first.
Problem
A Tart VM keeps running when the runner inside it exits.
WaitInstanceonly watched the VM'start runprocess, 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-runnersis the only way to keep a runner ready, which the next PR in this stack makes it.Fix
WaitInstancenow also checks the runner process (pgrep -f Runner.Listenerthroughtart exec) every 20 seconds, and returns once three checks in a row found none.No new configuration.
Tests
In
internal/provider/tart_liveness_test.go:TestTartProvider_WaitInstanceReportsRunnerThatDiedWaitInstancenever returnsTestTartProvider_WaitInstanceToleratesRunnerRestartTestTartProvider_WaitInstanceIgnoresChecksThatFailedTestTartIntegration_WaitInstanceReportsRunnerThatDieddoes 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 ./...andgolangci-lint run ./...pass.Not verified
Runner.Listenerand that a self-update keeps it absent for less than 40 seconds. Both were tested with a stand-in runner only.