Repository navigation
extend: carry the cost limit along with the TTL - #641
Merged
Merged
Conversation
'spawn extend' moved spawn:ttl and spawn:ttl-deadline and nothing else — grep -ci cost
cmd/extend.go was 0 — while spored enforces the cost cap INDEPENDENTLY
('first-to-fire wins', pkg/agent/agent.go). So for anyone who sized their cap to their
TTL, which is what the cost guidance tells you to do, extend was a no-op BY
CONSTRUCTION: the limit it left alone was always the tighter one.
The reported case: a 60m TTL capped at $0.65 on a $0.63808/hr instance (61 minutes of
spend), extended by 45m. The TTL moved to 105m, the cap stayed, and the instance still
stopped at ~61m — one minute after the ORIGINAL deadline. Nothing in the output
mentioned the cap, so it read as 'extend didn't work' rather than 'a second limit
fired'. The workaround was writing the tag by hand.
The cap is now raised to exactly what the new deadline requires: rate x hours from
LaunchTime to the new deadline, including the EBS rate because the cap counts EBS too
(#616) and a compute-only figure would bind early again — the same bug one layer down.
Both rates come from the instance's own tags, so this cannot disagree with what is
actually enforced. Not proportional scaling, which would guess.
It only ever RAISES: an extension is a decision to allow more spend, not less, and
silently tightening someone's cap would be its own surprise. --cost-limit sets a value
explicitly; --keep-cost-limit opts out and still prints that the cap was left alone,
because otherwise the user is back to an instance dying early for an unstated reason.
Where the required cap is unknowable — no spawn:price-per-hour, no launch time — it
says so instead of inventing a number. Guessing is how #533's cap stopped being
enforceable.
Output for the reporter's exact case:
Cost limit: $0.6500 -> $1.1166
(raised: $0.6500 capped this instance at 1h1m, so the new deadline
was unreachable)
Job arrays are NOT fixed here and now warn instead, naming the per-instance command:
that path writes a relative spawn:ttl rather than a deadline, so the required cap has
to be derived from a different anchor. Deliberately separate, but not left silent.
Refs #639
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #639. Per your call: raise the cap to exactly what the new TTL needs, with
--cost-limitto set it explicitly and--keep-cost-limitto opt out.The bug, and why it's a no-op by construction
spawn extendmovedspawn:ttlandspawn:ttl-deadlineand nothing else —grep -ci cost cmd/extend.gowas 0 — whilesporedenforces the cost cap independently:// 3. Check cost limit (fires independently of or alongside TTL — first-to-fire wins)"First-to-fire wins" is right. The gap was that
extendcould only move one of the two. And anyone who sized their cap to their TTL — which is what the cost guidance tells you to do — hadextendbe a no-op by construction: the limit it left alone was always the tighter one.The reported case: a 60m TTL capped at
$0.65on a$0.63808/hrinstance (61 minutes of spend), extended by 45m. TTL moved to 105m, cap stayed, instance still stopped at ~61m — one minute after the original deadline. Nothing in the output mentioned the cap, so it read as "extend didn't work" rather than "a second limit fired."The fix
needed = rate × hours from LaunchTime to the new deadline, whererateincludes the EBS rate — because the cap counts EBS too (#616) and a compute-only figure would bind early again, which is the same bug one layer down. Both rates come from the instance's own tags (spawn:price-per-hour,spawn:ebs-hourly-cost), so this cannot disagree with what is actually enforced.Not proportional scaling, which would guess. This computes exactly what the TTL you asked for requires.
It only ever raises. An extension is a decision to allow more spend, not less; silently tightening a cap someone set deliberately would be its own surprise.
Where the answer is unknowable, it says so rather than inventing a number — no
spawn:price-per-hour, no launch time → the cap is left alone with the reason printed. Guessing is how #533's cap stopped being enforceable.--keep-cost-limitstill prints that the cap was left alone, because otherwise the user is straight back to an instance dying early for an unstated reason, which is the actual complaint.Job arrays: not fixed, but no longer silent
The array path writes a relative
spawn:ttlrather than a deadline, so the required cap has to be derived from a different anchor — a separate change. It now warns and names the command that does work:Deliberately scoped out, deliberately not left as a hidden trap.
Tests
Eight cases, pure (no AWS): the reporter's exact numbers (
$0.65/$0.63808/hr / +45m → ~$1.1166, with a reason naming both what was raised and why); EBS raising the required cap; never lowering a cap that already covers the deadline;--cost-limitwinning;--keep-cost-limitrespected and explained in the output; no cap being a non-event; a missing rate producing an explanation rather than a number; and the tag format matching what launch writes sosporedparses it identically.Gates
gofmt·go vet·go build·go test ./...all green ·make check-docsclean withdocs-gen/extend.mdregenerated · changelog format tests pass ·staticcheckzero added (by-message diff).Note on ordering
This branches off
main, so it's independent of #640 (#616,--cost-limitcovers storage) — but the two are related: this includes the EBS rate in its arithmetic, which matches what the cap enforces exactly once #640 lands. Before that it just leaves slightly more headroom, which is the safe direction. No merge-order dependency either way.Suggested bump: MINOR — two new flags on
extend, and a cap that now moves when you extend.