Repository navigation
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This was referenced Oct 15, 2026
Merged
Three problems on one status screen: - Spot instances were labelled "(spot)" but costed at the on-demand rate. A spot launch now records spawn:spot-price-per-hour (DescribeSpotPriceHistory for the instance's AZ, type and platform); spored status and spawn's own max-cost and billable-resources lines use it. Older instances get the current spot price via the caller's credentials; with neither, the on-demand rate is used and labelled as an overstatement. --cost-limit stays on-demand. - `spored status` is a fresh process and counted compute from its own start, leaving only the spawn:compute-seconds checkpoint (0 on a new instance) and a boot term equal to all of elapsed. The daemon now publishes its compute clock in /run/spored and status adopts it (validated against instance id and boot time). Boot time is billed. Cost shows "—" with no running time; the effective rate needs a minute and the live clock, so a ratio of zeros never reads as a saving. - The TTL line was UTC and the termination deadline local. Every time on the screen is now "local (UTC)", including spored's re-rendered timestamps.
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.
Root causes
spawn:price-per-hour, which is the on-demand rate resolved at launch for--cost-limit. No spot price was ever recorded, and the(spot)label was only cosmetic.0sof compute at 47s elapsed.spored statusis a fresh process (NewAgentForQuery), so itsstartTimeis "now".TotalComputeSeconds()came out as thespawn:compute-secondscheckpoint plus about 0. That checkpoint is 0 until the daemon's first write, and after that it lags by up to 5 minutes. The same wrong clock made the "boot" term equal to all of elapsed and kept "stopped" from ever showing. The effective rate was then$0 / elapsed, compared against on-demand: "100% lower".Termination deadlineprintedtime.Local.Fixes
pkg/aws: a spotLaunchlooks upDescribeSpotPriceHistoryfor the instance's own AZ, type and product (mapped fromPlatformDetails). Unmapped platforms such as Windows+SQL or BYOL are reported as unknown, not priced as Linux. It then tagsspawn:spot-price-per-hour. This is best-effort and never fails the launch. New exportedSpotPriceTag,SpotPrice,(*Client).CurrentSpotPrice(additive only;make api-snapshotcommitted).Config.SpotPricePerHour) and charges compute at it when it is set. The JSON gainsrate_per_hourandrate_basis, andprice_per_hourstays as the on-demand baseline. A "Spot rate" line sits next to the unchanged "On-demand rate" line.--cost-limitenforcement and the "Cost limit" line stay on the on-demand rate. That is what enforcement measures, and it can only overstate spot spend.{instance_id, started_at, base_seconds}) to/run/spored/compute-clock.json./runis tmpfs, so the file is cleared by a stop/start.spored statusadopts the clock after checking it: the instance id must match, the start must not be in the future, and it must not predate the current boot (/proc/uptime). The billed time is compute plus the boot gap, because EC2 bills fromrunning.—until there is at least 1s of running time. The effective rate and its saving require the live clock, a known EBS rate and 1 minute elapsed, and are computed from unrounded figures. A ratio of zeros can no longer read as a saving.formatStatusTimegives local time with UTC in parentheses (2026-10-15 10:59 MST (17:59 UTC), and just UTC when local is UTC). spawn re-renders spored'sYYYY-MM-DD HH:MM UTCtimestamps (Started, TTL) into that format for display only; the notices still parse the original text. Termination deadline and the lifecycle-mismatch warning use the same helper. spored's TTL line becomes— terminates …to avoid nested parentheses.Tests
All unit tests, with mocked EC2 and stub providers. No AWS resources were created.
cmd/spored/status_cost_test.go: spot costed at spot (issue's m8a.4xlarge numbers), with the cost limit still on-demand. Spot with no recorded price is labelled. The query process counts the daemon's running time (47s scenario). No running time means no saving, on both the checkpoint path and the live-clock path.pkg/agent/computeclock_test.go: a query agent is not live until it adopts a clock. Adoption is checked through the file round trip, and the test confirms it refuses another instance, a pre-boot clock, a future clock, a clock with no start and a negative base.pkg/aws/spotprice_test.go: the instance's own AZ is used, the newest observation wins, a failure writes no tag, the product mapping is correct, and the instance is re-described when the response is incomplete.cmd/status_spot_time_test.go: billable row and max cost use the spot price; lookup and labelled fallback work; on-demand instances make no lookup;formatStatusTimebehaves as specified; every timestamp on the composed screen (spored lines in both old and new formats, deadline block, mismatch warning) uses the single format.make checkpasses, apart fromTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker. That test needs a running Docker daemon, which was not available locally, and the change doesn't touch it. Cross-compiled vet passes forGOOS=windowsandGOOS=linux.Caveats
spawn upgrade-spored). Older agents keep their old output, but spawn's own lines (time format, max cost, billable row) are fixed regardless.Fixes #896