Skip to content

Spot replacement self-retirement (#1008) STOPS the replacement instead of ending it: untagged, request cancelled, EBS bills forever #1080

Closed

Description

@scttfrdmn

Found validating v0.131.0 live (2026-10-17, account 435415984226, us-east-1, released CLI + spored 0.131.0).

Test: persistent --spot t3.micro (--idle-timeout 50m --ttl 1h; request sir-f36qmbej), original i-089f582ef1ba3b4ac terminated outside spawn at 16:15:16Z.

time (UTC) event
16:16:49 EC2 launches replacement i-0d3a7006f2833a22e, 0 tags
16:17:52 its spored cancels the request (request-canceled-and-instance-running) ✅
16:18:23 instance stopped ❌; instanceInitiatedShutdownBehavior = stop

What #1008 intended: pkg/spotrequest.RetireReplacement "ends a replacement": cancel the request, then an OS shutdown. Its comment reasons about what happens "if EC2 terminates the instance". The design assumes the shutdown terminates. It doesn't: spawn never sets InstanceInitiatedShutdownBehavior (grep -rn InstanceInitiatedShutdownBehavior pkg cmd finds nothing), so EC2's default stop applies.

Result, which is worse than it looks: a stopped, untagged instance whose request is cancelled.

  • Nothing will ever start it. A stopped persistent-Spot instance restarts only through its request, and that's now cancelled.
  • Nothing will end it. The reaper's ec2:TerminateInstances is tag-scoped (TTL reaper cannot terminate an untagged replacement launched by a leaked persistent Spot request #984), so its sweep classifies this as a replacement and reports SPOT REPLACEMENT NOT TERMINATED (evaluateSpotRequest counts stopped as live) every 10 minutes until a person acts. It's invisible to spawn list.
  • Its EBS root volume bills indefinitely.

In fairness, it is strictly better than v0.130.1, where the replacement kept running with no TTL. The relaunch loop is closed (cancel worked within about a minute). What's left is an alarmed storage leak.

Fix options (each needs real-AWS verification; see #1069 for why a simulator pass is not enough):

  1. Let the instance terminate itself. Grant the instance role ec2:TerminateInstances on its own ARN, independent of tags, via the self-reference pattern (Condition: StringEquals aws:ARN = ${ec2:SourceInstanceARN}, or the documented equivalent). That narrows it to "this instance only", which is the property the tag scope approximates. It uses a policy variable, so prove it with a real PutRolePolicy and a real self-terminate before shipping.
  2. Make the OS shutdown terminate. Set InstanceInitiatedShutdownBehavior=terminate where the replacement would inherit it. It's unverified whether a persistent request's launch specification carries this attribute to its replacements at all, and whether it's allowed alongside InstanceInterruptionBehavior=stop. Check before relying on it.
  3. Fall back loudly. If neither is possible, spored should at least say in its log, and in the spot_replacement_retired notification, that the instance is being stopped and still needs terminating, and give the command, not imply it ended.

The test was cleaned up by hand: replacement and original terminated, volume deleted, 0 open/active requests, 0 leaked instances.

Activity

  1. scttfrdmn commented on Oct 17, 2026

    @scttfrdmn
    ContributorAuthor

    Verified live on v0.131.1 (released CLI + spored; 2026-10-17, account 435415984226, us-east-1).

    Persistent --spot t3.micro orphan-r3, request sir-bw5znqij (ValidUntil = TTL deadline). Original i-03738794bdf728d7e terminated outside spawn at 17:56:16Z.

    UTC event
    17:57:40 EC2 launches replacement i-03cdf8b294db89047 (untagged)
    17:58:11 CancelSpotInstanceRequests OK, then TerminateInstances OK. CloudTrail principal for both: assumed-role/spored-instance-role/i-03cdf8b294db89047, i.e. the replacement itself
    17:58:45 replacement terminated (v0.131.0: stopped)

    No manual cleanup was needed. Afterwards: 0 leaked instances, 0 open/active Spot requests, 0 available volumes, 0 DNS records. Neither the reaper nor an operator was involved; the leak now closes itself about 30 seconds after the replacement boots.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions