Repository navigation
Merged
Conversation
… 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 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.
Fixes #992. Stacked on #1027 (#990), which is stacked on #993 (#983). Base is
fix/990.The bug
computeExtendedTTLTagsanddecideCostLimitanchored toaws.InstanceInfo.LaunchTime, which is EC2'sLaunchTimeand resets on every start. This affected both the single-instance path and, since #983, the job-array path, which sharesextensionTags. After a stop/start:spawn:ttlwas 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).--cost-limitauto-raise pricedrate × (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
originalLaunchTime: returnsspawn:launch-time(written once at launch, and what spored, the reaper andconfig set ttluse). EC2LaunchTimeis only the fallback.spawn:ttlis rendered from it.pkg/agent.accumulatedComputeCost, consistent with Stopped instances: 'spawn status' SSHes to ::1 (localhost) and fails; compute from earlier runs is dropped after restart; stop message says TTL pauses but it doesn't #928/Status for stopped instances from EC2; compute kept across stop/start; stop's TTL message (#928) #947's cumulative compute). It assumes the instance runs until the deadline, which is the worst case:price × (compute so far + now→deadline) + EBS rate × (original launch→deadline).spawn:compute-secondspluscomputeTagLag(5m, the agent's longest write interval; the shutdown flush can be lost), capped at the wall-clock time since the original launch.spawn:ttl-deadline: extend now adds tolaunch + spawn:ttl, the deadline that is actually enforced (spored's synthesis, and the reaper's fallback from spawn launch --ttl 1d writes spawn:ttl=1d with no spawn:ttl-deadline, so neither spored nor the reaper enforces the TTL #990). It used to add tonow + spawn:ttl, which also handed back all the time already elapsed.TestComputeExtendedTTLTags_NoDeadlineTagFallsBackToTTLasserted the old behaviour. I changed it to the stated intent ("extending adds to the current deadline, not to the current clock time"), per CLAUDE.md rule 5.Tests (each watched failing against a compiling revert)
cmd/extend_restart_anchor_test.go:originalLaunchTimefalls back correctly;originalLaunchTimeto return EC2LaunchTime: 5 tests fail. RevertcomputeSoFarto ignorespawn:compute-seconds: 2 tests fail. The old no-deadline fallback fails the updated test.decideCostLimittests take an explicitnowand pass unchanged. With no compute tag the new formula reduces to the old one, anchored to the original launch.make checkis green apart from the known Docker-onlyTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker.make check-nestedis clean,golangci-lint --new-from-rev=HEADreports 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>andspawn listAge, which still use EC2LaunchTime. It needs coordinating with #947.