Skip to content

cleanup: keep runners' snapshot AVDs, stop orphaned CI emulators cleanly - #117

Merged
addisdev merged 1 commit into
mainfrom
cleanup/keep-snapshot-avds
Oct 23, 2026
Merged

addisdev merged 1 commit into
mainfrom
cleanup/keep-snapshot-avds

Conversation

@addisdev

Copy link
Copy Markdown
Owner

Why

The owner turned on the launch kit's android-ci emulator_snapshot for greenfolio-android, aliquant-android, dozehound-firetv and jerv. Each runner then keeps an AVD ci-<runner>-a<api>-<target>-<profile> with a quick-boot snapshot (~6 GB) that its next job boots from. cleanup.sh deleted every idle runner's ci- AVD after 30 minutes, so the next job would boot three times (initialise, save, test) instead of once.

What

  • Snapshot AVDs are kept while their runner exists, until FLEET_CLEANUP_AVD_KEEP_DAYS (14) without a boot. Their total stays under FLEET_CLEANUP_AVD_KEEP_GB (30, the owner's accepted cost) by dropping the least recently used idle snapshots/ (the AVD stays; the next job only saves a new snapshot). That check also runs on a quiet --auto tick. Below the admission floor every idle snapshot goes first, before any other step. Plain ci-<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-*).
  • Orphaned CI emulators: 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 (no Runner.Worker under its dir) or is gone (10-23: two greenfolio emulators ran 9 h after cancelled jobs; shims/ps answers the runner's own orphan scan, so nothing stopped them). Always adb emu kill first, then SIGTERM, SIGKILL last; a save-capable boot that needed SIGKILL has its snapshot dropped (it may have been mid-save).
  • Tests: scripts/test-cleanup.sh +4 cases (keep/stale/gone/collision ultra-jerv vs ultra-jerv-2, floor, budget LRU, orphan stop incl. escalation), new hooks/tests/emulator.sh (owner matching, job-end stop, off switch), wired into CI. Docs and CHANGELOG.

Local: test-cleanup.sh 109/0, hooks/tests/emulator.sh 17/0, other hook suites green, shellcheck clean, check-docs.sh ok.

Deploy: detached idle-wait on ultra, as d4f9b89 (~/deploy-after-<sha>.log); hooks are read in place.

🤖 Generated with Claude Code

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>
@addisdev
addisdev merged commit 249ad8a into main Oct 23, 2026
19 of 20 checks passed
@addisdev
addisdev deleted the cleanup/keep-snapshot-avds branch October 23, 2026 17:44
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