Repository navigation
Anchor status/cost/list age, TTL and cost to the first launch (#1029) - #1213
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
EC2's LaunchTime is the latest start. spawn status's TTL fallback and max compute cost, spawn list's Age, spawn cost and spawn task diagnose all measured from it, so after a stop/start they disagreed with what spored and the TTL reaper enforce. ttl.LaunchAnchor is now the one rule (the earlier of spawn:launch-time and EC2 LaunchTime, GHSA-c93q); the reaper's launchTime and cmd's originalLaunchTime both call it. Compute figures come from spored's spawn:compute-seconds. A discovery test keeps every other cmd/ reader of .LaunchTime off arithmetic.
scttfrdmn
force-pushed
the
fix/1029-launch-anchor
branch
from
October 20, 2026 05:33
bcc7c12 to
93ebdc6
Compare
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.
Fixes #1029
What changed
EC2's
LaunchTimeis the most recent START, so it resets on every start of a stopped instance. These display paths measured from it and, after a stop/start, disagreed with what spored and the TTL reaper enforce:lifecycleDeadlinefallback (nospawn:ttl-deadline) —spawn status,spawn listTTL column,spawn startnoticespawn:ttlspawn:ttlspawn status"Max compute cost"spawn extendalready sizes--cost-limitwith (decideCostLimit)spawn cost <instance>spawn listAge, sort orderspawn task diagnoseAge / Est. costOne rule, shared with enforcement. New
ttl.LaunchAnchor(tag, ec2Launch)inpkg/ttl: the EARLIER ofspawn:launch-timeand EC2 LaunchTime. That is exactly the reaper's rule after GHSA-c93q-4jh7-6pvj;lambda/ttl-reaper'slaunchTimenow delegates to it (behaviour unchanged, so no redeploy is needed) and so doescmd'soriginalLaunchTime(used byextendand the stopped-instance status since #992/#947). The only change tooriginalLaunchTimeitself: aspawn:launch-timeLATER than EC2's LaunchTime (forged, or a few seconds of clock skew at launch) no longer wins, so the CLI can't show an instance as younger than the reaper treats it.What "cost so far" means across stop/start (the choice). EC2 bills compute only while running, and EBS on the wall clock including stopped time. So:
spawn:price-per-hour× spored's cumulativespawn:compute-seconds. That is the same total--cost-limitis enforced against (pkg/agent.accumulatedComputeCost). There are no otherspawn:cost-*tags besidesspawn:cost-limit, so this tag is the source. Shown as-is (nocomputeTagLagpadding; the report says it can be up to 5 min behind while running).spawn:ebs-hourly-cost× time since first launch, shown when the tag is present (matching the stopped-instancespawn statusfrom Status for stopped instances from EC2; compute kept across stop/start; stop's TTL message (#928) #947).computeSoFar(tag + 5 min lag, capped at wall clock) plus the remaining time, the same asspawn extend. That makes it a ceiling, not an estimate.spawn listAge is now the time since first launch. That is the age the reaper's max-age ceiling acts on, as the issue suggests.-o jsonkeepslaunch_time(EC2's, the latest start) and addsfirst_launch_time. Both are recorded in the CHANGELOG (Changed / Added).Coordination with #947 (merged): it kept the Max compute cost line as is and deferred it to this issue. The stopped-instance status it added already used
originalLaunchTime/taggedComputeSeconds, and this PR reuses them.Gates
TestRestartedInstanceIsShownFromItsFirstLaunch: LaunchTime = 1h ago,spawn:launch-time= 3d ago,spawn:ttl=96h, 5h ofspawn:compute-seconds. It asserts the deadline is tag + 96h,spawn list's rendered Age column is3dand its TTL ~23h,spawn costshows 3d since launch / 5h compute / $5.00 (and "at most" figures without the compute tag), and status max cost is ~$29.08.TestNoDisplayDurationFromRawLaunchTime: an AST discovery over every non-testcmd/*.go. Each.LaunchTimeselector must be inoriginalLaunchTime, or else used only for ordering (.After/.Before/.Equal), raw export (.Format) or a struct copy. It fails if discovery finds nothing.TestOriginalLaunchTimeIsTheEarlierOfTagAndEC2,pkg/ttl TestLaunchAnchor.Each gate was watched failing against a revert that compiles:
time.Since(inst.LaunchTime): Age = "1h" + discovery flags list.go:274.instance.LaunchTime.Add(d): deadline/TTL "3d22h"/max cost subtests + discovery flag status.go.age := time.Since(inst.LaunchTime): discovery flags task.go:84.deadline.Sub(instance.LaunchTime): max-cost subtest + discovery.originalLaunchTimetag-first: the earlier-of test.Checks
make check: fmt/vet (all GOOS)/staticcheck/hermetic short tests/tidy all pass.check-build-tagsfails, and it fails identically on unmodified main on this machine (/private/tmpworktree paths).make gen-docs(cost.md regenerated) and thenmake check-docsclean. semgrep: 0 findings.lambda/ttl-reapertests pass.