Skip to content

e2e Tier 2/3 tests leak instances — cleanup stops instead of terminating, no reaper safety net #47

Closed

Description

@scttfrdmn

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.Cleanup doesn'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)

  1. Cleanups must terminate. Change Tier 3 stop → terminate --yes (and terminateByName → actually terminate, fix the name + comment). Stopping is never the right cleanup for an ephemeral test instance.

  2. Belt-and-suspenders TTL. Every launch helper already sets --ttl; keep it short (e.g. ≤15m) and also set --on-complete terminate so completion or TTL both lead to termination, not stop.

  3. A reaper. Add a sweep that runs at the start and end of every tiered run (e.g. TestMain) which terminates any instance tagged spawn: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 that t.Cleanup can't.

  4. A leak-check assertion. A Tier 1-cheap test (API-only) that fails if any spawn:e2e=true instance is older than a threshold — turns silent leakage into a red build.

  5. 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=true instance outlives its TTL window.
  • terminateByName actually terminates (or is renamed stopByName and 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions