Repository navigation
cleanup: keep runners' snapshot AVDs, stop orphaned CI emulators cleanly - #117
Merged
Merged
Conversation
The launch kit's android-ci emulator_snapshot boots each runner's emulator from a quick-boot snapshot kept in its own AVD (ci-<runner>-a<api>-<target>-<profile>). cleanup.sh deleted every idle runner's ci- AVD after 30 minutes, which would make the next job boot three times instead of once. - Snapshot AVDs of runners that exist are kept until 14 days without a boot (FLEET_CLEANUP_AVD_KEEP_DAYS). Their total is held under FLEET_CLEANUP_AVD_KEEP_GB (30) by dropping the least recently used idle snapshots/ (the AVD stays), also on a quiet --auto tick; below the admission floor every idle snapshot goes before any other step. Plain ci-<runner> AVDs (recreated every job) and AVDs of gone runners still go. - hooks/emulator-control.sh: the job-completed hook stops an emulator the job left on its runner's AVD, and every cleanup tick stops one whose parent is launchd and whose runner runs no job (two greenfolio emulators ran 9 h after cancelled jobs on 10-23). adb emu kill, then SIGTERM, SIGKILL last, dropping the snapshot of a save-capable boot that needed SIGKILL. - Tests: scripts/test-cleanup.sh (snapshot keep/stale/gone, floor, budget, orphans), hooks/tests/emulator.sh (owner matching, job-end stop). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
The owner turned on the launch kit's android-ci
emulator_snapshotfor greenfolio-android, aliquant-android, dozehound-firetv and jerv. Each runner then keeps an AVDci-<runner>-a<api>-<target>-<profile>with a quick-boot snapshot (~6 GB) that its next job boots from.cleanup.shdeleted every idle runner'sci-AVD after 30 minutes, so the next job would boot three times (initialise, save, test) instead of once.What
FLEET_CLEANUP_AVD_KEEP_DAYS(14) without a boot. Their total stays underFLEET_CLEANUP_AVD_KEEP_GB(30, the owner's accepted cost) by dropping the least recently used idlesnapshots/(the AVD stays; the next job only saves a new snapshot). That check also runs on a quiet--autotick. Below the admission floor every idle snapshot goes first, before any other step. Plainci-<runner>AVDs (recreated every job by android-emulator-runner) and AVDs of runners that no longer exist still go after 30 idle minutes. Never a building runner's, an open one, one written in the last 30 min, or a non-runner AVD (fleet-explore-*).hooks/emulator-control.sh. The job-completed hook stops an emulator the job left on its runner's AVD; every cleanup tick stops one whose parent is launchd, older than 5 min, whose runner runs no job (noRunner.Workerunder its dir) or is gone (10-23: two greenfolio emulators ran 9 h after cancelled jobs;shims/psanswers the runner's own orphan scan, so nothing stopped them). Alwaysadb emu killfirst, then SIGTERM, SIGKILL last; a save-capable boot that needed SIGKILL has its snapshot dropped (it may have been mid-save).scripts/test-cleanup.sh+4 cases (keep/stale/gone/collisionultra-jervvsultra-jerv-2, floor, budget LRU, orphan stop incl. escalation), newhooks/tests/emulator.sh(owner matching, job-end stop, off switch), wired into CI. Docs and CHANGELOG.Local:
test-cleanup.sh109/0,hooks/tests/emulator.sh17/0, other hook suites green, shellcheck clean,check-docs.shok.Deploy: detached idle-wait on ultra, as d4f9b89 (
~/deploy-after-<sha>.log); hooks are read in place.🤖 Generated with Claude Code