Skip to content

fix: spawn:ttl now tracks the cumulative total, not the raw extend argument - #513

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/506-extend-ttl-tag-semantics
Aug 18, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/506-extend-ttl-tag-semantics

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

spawn extend correctly advanced spawn:ttl-deadline (the absolute timestamp spored and the out-of-band reaper actually enforce) but rewrote spawn:ttl to the literal <duration> argument on every call — so it stopped meaning "total TTL duration from launch," which is what every other reader of the tag expects. A repeated extend <id> 8h looked unchanged even though the deadline had genuinely moved twice — reported live as "extend rewrites spawn:ttl-deadline and leaves spawn:ttl at the original 8h... two tags for one fact, only one of them moving."

This had a real behavioral consequence beyond the confusing display: spawn stop/hibernate's remaining-TTL preservation computed spawn:ttl + LaunchTime directly, silently ignoring any extend calls made since launch. A stop/start cycle after an extend would restore the wrong (un-extended) TTL.

Fix

  • spawn:ttl is now recomputed as newDeadline - LaunchTime — the actual cumulative total — instead of echoing the raw extend argument.
  • spawn stop/hibernate's remaining-TTL calculation (both the single-instance and job-array paths) now derives from the authoritative spawn:ttl-deadline tag via the existing lifecycleDeadline helper, same as spawn status already did, instead of instance.TTL + LaunchTime directly.
  • Extracted the tag-computation logic out of runExtend into a pure computeExtendedTTLTags function so it's unit-testable without a real AWS client.
  • spawn extend's own output now separates "Extended by" (the argument) from "New TTL" (the resulting cumulative total) and the resolved deadline, instead of one ambiguous "New TTL" line that showed the raw argument.

Fixes #506.

Test plan

  • New tests: TestComputeExtendedTTLTags_DeadlineAdvancesAndTTLTracksTotal (also asserts a second extend visibly changes spawn:ttl again), TestComputeExtendedTTLTags_FloorPreventsImmediateReap, TestComputeExtendedTTLTags_NoDeadlineTagFallsBackToTTL, TestLifecycleDeadline_ReflectsExtendNotJustLaunchPlusTTL
  • Verified the main regression test fails without the spawn:ttl fix (reverted just that line, confirmed FAIL) and passes with it
  • go build ./..., go vet ./..., go test ./cmd/... all clean
  • golangci-lint run ./cmd/... — no findings in touched files
  • make gen-docs — no drift (only runtime output changed, not flag/help text)
  • CHANGELOG.md updated under ## [Unreleased]

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.45455% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/extend.go 62.50% 7 Missing and 2 partials ⚠️
cmd/state.go 0.00% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

…gument

extend correctly advanced spawn:ttl-deadline (the tag spored and the reaper
actually enforce) but rewrote spawn:ttl to the literal <duration> argument
each call, so it stopped meaning "total duration from launch" -- what every
other reader of the tag expects. A repeated `extend <id> 8h` looked
unchanged even though the deadline had genuinely moved twice.

stop/hibernate's remaining-TTL preservation computed from spawn:ttl +
LaunchTime directly, so it silently ignored any extend calls made since
launch -- a stop/start cycle after an extend could restore the wrong TTL.
Both call sites now derive remaining TTL from the authoritative
spawn:ttl-deadline tag via lifecycleDeadline, same as spawn status already
did.

Extracted the tag-computation logic into a pure computeExtendedTTLTags so
it's unit-testable without a real AWS client.

Fixes #506
@scttfrdmn
scttfrdmn force-pushed the fix/506-extend-ttl-tag-semantics branch from c41b383 to b3efa9d Compare August 18, 2026 07:11
@scttfrdmn
scttfrdmn merged commit 4218164 into main Aug 18, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant