Skip to content

Instance left running with no safety net when post-launch verification fails (terminate-on-error defaults to false) #1298

Closed

Description

@scttfrdmn

What happened

spawn launch (v0.135.1) created an on-demand g5.xlarge with --ttl 4h --cost-limit 5 --on-complete terminate. RunInstances succeeded: one CloudTrail event, no errorCode. The guest then never booted far enough to start spored; CloudTrail shows zero API calls from the instance, not even SSM registration. After about 7 minutes of post-launch checks, spawn returned:

instance … launched but spored never came up — it has NO TTL/idle safety net …

and exited non-zero without terminating the instance, because --terminate-on-error defaults to false. The caller saw a failed launch and moved on.

  • Result: the instance ran about 74 hours, past its TTL and cost limit, at about $75 on-demand.
  • Why nothing else stopped it: TTL and cost-limit enforcement lives only in spored, in the guest. The account's selfscan reaper was deployed with REAPER_REGIONS set to one region, and the instance was in another.

Code references (HEAD 76ebc33)

  • cmd/launch_single.go:988 → cmd/launch_posthook.go:405-429: on a verification failure, the instance is terminated only if --terminate-on-error, which defaults to false (cmd/launch_flags.go:445).
  • cmd/launch_single.go:902, the WaitForRunning error, and :911, the GetInstancePublicIP error, return the error without terminating the instance. The --fsx-create path in pkg/launcher/provision.go:174-182 does terminate.
  • cmd/launch_reaper_coverage.go (launchLeansOnReaper) warns about reaper coverage only for stop/hibernate or ephemeral FSx, never for --on-complete terminate.
  • The reaper code itself defaults to 11 regions (pkg/reaperconfig/reaperconfig.go:189-196). The gap was a deployment setting.

Suggested fixes

  1. Terminate by default on any failure after RunInstances: verification, WaitForRunning, public-IP lookup. Keep an explicit opt-out (e.g. --keep-on-error), and print the instance ID before anything else.
  2. Warn or refuse when the launch region is outside the deployed reaper's coverage, for every on-complete mode. An instance whose guest never starts spored has only the reaper.
  3. (Optional) Reap early on a missing heartbeat: no heartbeat N minutes after launch reaps the instance, without waiting for the TTL deadline.

Test plan

  • Unit tests with the sporedSignals fake and a fake terminator. With default flags, each of these must call Terminate exactly once: a verification timeout, a WaitForRunning error, and a public-IP error. The opt-out must skip Terminate.
  • Launch-time test: a region outside DetectReaperCoverage triggers the warning for --on-complete terminate.
  • Integration test: user-data that prevents the agents from starting; the CLI must terminate the instance within its verification budget.

Workaround for callers today: pass --terminate-on-error, and sweep by tag after any failed launch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions