Skip to content

spawn extend anchors spawn:ttl and the raised cost limit to EC2 LaunchTime, which resets on every start #992

Closed

Description

@scttfrdmn

Found while fixing #983. I read the code and did not reproduce this live.

computeExtendedTTLTags and decideCostLimit (cmd/extend.go, cmd/extend_cost_limit.go) both anchor to aws.InstanceInfo.LaunchTime. pkg/aws/client.go fills that field from EC2's LaunchTime, and EC2 resets it on every start of a stopped instance. Everything else uses the original launch:

  • spawn:launch-time is tagged once at launch (pkg/aws/tags.go). spored reads it into config.LaunchTime, and so does pkg/ttl.SetTags via spored config set ttl.
  • The cost cap counts accumulated compute across all boots (spawn:compute-seconds, pkg/agent/agent.go).

So after a stop/start, spawn extend (single instance and, since #983, the job-array path too):

  1. writes spawn:ttl = new deadline minus the latest start. The tag is meant to be the total from launch (extend: spawn:ttl tag is overwritten with the extend argument, not the cumulative total — every other reader still treats it as the launch-anchored duration #506). The deadline itself is unaffected, and spored reads the deadline, so this is a labelling error.
  2. computes the cap that --cost-limit auto-raise needs as rate x (deadline - latest start). That leaves out compute from earlier boots, so the raised cap can still fire before the new deadline, which is the spawn extend moves the TTL but not the cost limit, so it is a no-op on any task whose cap was sized to its TTL #639 trap again.

Suggested fix: anchor both to spawn:launch-time when it is present and fall back to EC2 LaunchTime. For (2), use the accumulated compute from spawn:compute-seconds plus the time from now to the deadline, which matches the arithmetic the agent actually enforces.

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