Skip to content

Anchor spawn extend's spawn:ttl and raised cost limit to the original launch and cumulative compute (#992) - #1030

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/992
Oct 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/992

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #992. Stacked on #1027 (#990), which is stacked on #993 (#983). Base is fix/990.

The bug

computeExtendedTTLTags and decideCostLimit anchored to aws.InstanceInfo.LaunchTime, which is EC2's LaunchTime and resets on every start. This affected both the single-instance path and, since #983, the job-array path, which shares extensionTags. After a stop/start:

  1. spawn:ttl was written as the new deadline minus the latest start. It is supposed to be the total from the original 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).
  2. The --cost-limit auto-raise priced rate × (deadline − latest start). That left out the compute from earlier boots, so the "raised" cap could still stop the instance 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.

The fix

Tests (each watched failing against a compiling revert)

  • New in cmd/extend_restart_anchor_test.go:
    • spawn:ttl is the total from the original launch;
    • the cap covers compute from every boot (7h so far + 6h more, plus 16h of EBS) and is no more than the tag lag above that;
    • a stopped instance's stopped time is not billed as compute;
    • the wall-clock fallback runs from the original launch;
    • originalLaunchTime falls back correctly;
    • the job-array path gets the same anchors.
  • Revert originalLaunchTime to return EC2 LaunchTime: 5 tests fail. Revert computeSoFar to ignore spawn:compute-seconds: 2 tests fail. The old no-deadline fallback fails the updated test.
  • The existing decideCostLimit tests take an explicit now and pass unchanged. With no compute tag the new formula reduces to the old one, anchored to the original launch.
  • make check is green apart from the known Docker-only TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker. make check-nested is clean, golangci-lint --new-from-rev=HEAD reports 0 issues and semgrep reports 0 findings.

Not in scope

#1029 (filed) covers spawn status's max-cost line, lifecycleDeadline's fallback, spawn cost <id> and spawn list Age, which still use EC2 LaunchTime. It needs coordinating with #947.

… launch and cumulative compute (#992)

EC2 resets LaunchTime on every start of a stopped instance, and extend
(single instance and, since #983, the job-array path) anchored both
spawn:ttl and the --cost-limit auto-raise to it.

- spawn:ttl is again the total from the original launch: anchored to
  spawn:launch-time, with EC2 LaunchTime only as a fallback.
- The raised cap mirrors the agent's enforced arithmetic: rate x (compute
  so far across every boot, from spawn:compute-seconds plus a bounded
  tag-write lag + now..deadline) + EBS rate x (original launch..deadline).
  With no compute tag it uses the wall-clock bound from the original
  launch, so the cap errs high, never low. Stopped time is no longer
  priced as compute.
- An old instance with no deadline tag is extended from launch + spawn:ttl
  (what spored and the reaper enforce), not now + spawn:ttl.

(#992)
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.75758% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/extend_cost_limit.go 74.07% 3 Missing and 4 partials ⚠️
cmd/extend.go 83.33% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 8753e6e into main Oct 17, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the fix/992 branch October 17, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant