Repository navigation
Description
Severity: high — this is the one bug an ephemeral-infra/cost-control project cannot tolerate
A Tier 1 leak-check found 67 leftover e2e instances in spore-host-dev from prior Tier 2/3 runs — one running for 12 days (e2e-test-queue-*), ~54 stopped for 1–2 weeks (accruing EBS), plus 12 stopped e2e-pg-region-* in us-east-2. (All terminated manually now.) The test suite is leaking the very resources the product exists to keep ephemeral.
Root causes (three compounding gaps)
1. Tier 3 cleanups STOP instead of TERMINATE.
test/e2e/tier3_test.go:36 spawnMayFail(t, "stop", "--job-array-name", arrayName)
test/e2e/tier3_test.go:172 t.Cleanup(func() { spawnMayFail(t, "stop", "--job-array-name", name) })
test/e2e/tier3_test.go:244 t.Cleanup(func() { spawnMayFail(t, "stop", "--job-array-name", name) })
Stopped instances live forever and keep paying for EBS. This produced the ~54 e2e-array-*/e2e-mpi-* leaks.
2. terminateByName is misnamed — it stops, not terminates.
// helpers.go:23 "terminateByName stops all instances with the given name."
So even Tier 2 paths that look like they terminate actually leave stopped instances.
3. No reaper / no guaranteed TTL enforcement.
- TTLs are set (
--ttl 20m), but TTL enforcement is spored's job. If spored never installs/boots (e.g. the queue test that ran 12 days), nothing reaps the instance. t.Cleanupdoesn't run if the test binary is killed (timeout, CI cancel, panic,^C) — so cleanup is best-effort, not guaranteed.
Proposed fixes (defense in depth)
-
Cleanups must terminate. Change Tier 3
stop→terminate --yes(andterminateByName→ actually terminate, fix the name + comment). Stopping is never the right cleanup for an ephemeral test instance. -
Belt-and-suspenders TTL. Every launch helper already sets
--ttl; keep it short (e.g. ≤15m) and also set--on-complete terminateso completion or TTL both lead to termination, not stop. -
A reaper. Add a sweep that runs at the start and end of every tiered run (e.g.
TestMain) which terminates any instance taggedspawn:e2e=true(add this tag to all test launches) older than N minutes — regardless of which test or prior run created it. This catches killed-process leaks thatt.Cleanupcan't. -
A leak-check assertion. A Tier 1-cheap test (API-only) that fails if any
spawn:e2e=trueinstance is older than a threshold — turns silent leakage into a red build. -
Tag all e2e launches with
spawn:e2e=true+ a run-id so the reaper/leak-check can target precisely and never touch non-test instances.
Acceptance
- No e2e test leaves a running OR stopped instance after a normal run.
- A killed/timed-out run is cleaned by the reaper on the next run's
TestMain. - CI fails if a
spawn:e2e=trueinstance outlives its TTL window. terminateByNameactually terminates (or is renamedstopByNameand callers fixed to terminate).
Context
Found while running Tier 1 against real AWS (spore-host-dev). Tier 1 itself is clean (API-only / --estimate-only, launches nothing). The leaks are entirely from Tier 2/3. Blocks doing Tier 2/3 runs safely.
Activity
test(e2e): cost-control safety net for real-AWS tiers (#47) (#48)
test(e2e): harden Tier 1 — assert real pricing values + cover capacit…
feat: verify spored came up on launch; fail if it didn't (#50) (#251)