Skip to content

A --cost-limit (or TTL) termination sends the --command process no signal and gives it no grace period #1554

Open

Description

@scttfrdmn

Split out of #1497, whose first half (Spot instances charged at the on-demand rate) is fixed by the PR linked there. This is its second half, which that PR does not touch.

What happens. When the cost limit fires, pkg/agent checkAndAct calls a.terminate(ctx, "cost limit reached ...", taskproto.ExitCostLimitExceeded). terminate (pkg/agent/agent.go) runs runPreStop (the task flush hook, then the user's --pre-stop if any), Cleanup, warns logged-in users, sleeps shutdownWarnDelay (5 s) and calls provider.Terminate. Nothing signals the --command process: there is no SIGTERM and no grace period, so the job is killed mid-step by the instance going away. The only syscall.SIGTERM handling in pkg/agent is queue_runner.go's own signal.Notify. The reporter's instance terminated 5 s after the job's last log sync, with no final log or result upload.

A spawn task run instance gets a terminal record and a command.log upload from the flush hook (#632, #1186). A plain spawn launch --command gets neither, unless the user has set --pre-stop.

Suggested (from #1497):

  • When a lifecycle limit fires, send SIGTERM to the --command process group, wait a configurable grace period (e.g. 2 min, bounded by the Spot notice on a Spot interruption), then terminate.
  • Tag the instance with the reason (for example spawn:terminated-by=cost-limit), so spawn list and CloudTrail show why. It needs a tag-reserve slot (pkg/aws post_launch_tags.go).
  • When the limit is below TTL x rate, say in the launch output that spawn extend --raise-cost-limit exists.

Refs #1497

Activity

  1. added this to the Hardening milestone on Nov 8, 2026
  2. added
    area:spored
    area:lifecycle
    spend-safety
    on Nov 8, 2026
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

    area:lifecyclearea:sporedspend-safetytype:bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions