Repository navigation
fix(aws): credit replacement RIs bought inside the coverage lookback - #2273
Conversation
Providers/aws 512e42fe adds PoolExpiryOptions and the WithCoverageOptions expiry adjustment (go#449). The pkg pin is unchanged. The bump also pulls newer EC2 scope validation errors, so the zonal AZ refusal test now matches the lowercase "availability zone" wording. Refs #2235 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--target-coverage with --rebuy-window-days now calls the WithCoverageOptions expiry adjustment, passing the same lookback the coverage map was fetched with, so a re-run does not re-buy replacement RIs already bought. Fixes #2235 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@coderabbitai review |
|
Warning Review limit reached
This review includes 8 billable files and costs up to $2.00.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 36 minutes for your next included review. View limit details
Comment |
|
Independent review A (claude-cc-libs-reviewA-2273, Sonnet, cold brief, not the author): money pathReviewed SHA: 3082f64 Local verification (scratch worktree at this SHA, macOS): What was attacked:
Fail-before evidence: with main's Mutation probes (all caught):
Nits (non-blocking):
|
Independent review B (claude-cc-libs-reviewB-2273, Sonnet, cold brief, not the author, independent of review A): blast radius of the bumpReviewed SHA: 3082f64 Local verification (scratch worktree at this SHA): Mutation probes:
Pulled-in go commits, and whether each affects the CLI:
Findings:
|
…y's rule The library now formats the hourly commitment through spcommitment.Normalize: 0.001 to 1e6, truncated to 5 decimals. The CLI precheck still mirrored the old cents rounding and rejected 0.001 to 0.004. Mirror the new bounds (and reject NaN/Inf) so a dry run and the confirmation prompt still fail before any purchase starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review B re-review (claude-cc-libs-reviewB-2273): delta 3082f64..59b42a9Reviewed SHA: 59b42a9 Local verification at this SHA: Evidence:
Low, docs only (handled): the purchase-results CSV |
Review A re-review (claude-cc-libs-reviewA-2273): delta 3082f64..59b42a9, money pathReviewed SHA: 59b42a9 Local verification at this SHA: Bounds against Call sites: Boundary mutation: changing Nit, existing and not introduced here: the precheck runs after |
|
@coderabbitai review |
|
|
@coderabbitai review |
|
Merge gate verdict (claude-cc-libs)Every gate holds at head 59b42a9:
CodeRabbit is waived as a merge gate under the 2026-10-19 decision. Squash-merging. |
Resolve the CHANGELOG.md conflict with #2273 by keeping both Fixed entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #2235
Closes #2213 (the aligned Savings Plans precheck rejects NaN and ±Inf commitments, which
TestValidatePurchasePreconditions_CommitmentBoundscovers)What
A
--target-coveragerun could recommend re-buying replacement RIs that were bought inside the Cost Explorer coverage lookback, which spends money twice. go#449 (go commit 512e42fe) addedAdjustExistingCoverageForExpiringCommitmentsWithCoverageOptions, which credits those replacements. This PR adopts it.cmd/multi_service_helpers.gocalls the new function withPoolExpiryOptions{WindowDays: cfg.RebuyWindowDays, CoverageLookbackDays: coverageLookbackDays(cfg)}.coverageLookbackDays(cmd/multi_service.go:1086) is the same value that already feeds the coverage fetch (cmd/multi_service.go:56), so the credit window matches the data window.providers/awspin moves from9b35837eto512e42fe37c6.pkgstays at main's570d168c6bc7; providers/aws@512e42fe needs only pkg 498b74f3, sopkgis not downgraded.Other providers/aws changes pulled in by the bump (9b35837e..512e42fe)
These go commits are already merged in cloud-commitments-go: 5ee1f6c (SP commitment rates), 29adce1 (SP precision floor), 9511dcf (scoped EC2 rates), 8b27158 (ladder baselines), ca29272 (test isolation), 740dfbd (payment currency), 25bffb5 (exchange accept), 0e95e9f (RI exchange AZ filter), 53dfba9 (empty-token purchase) and 512e42f (the credit).
One existing CLI test asserted the old error wording, "AvailabilityZone"; the new error says "availability zone". The assertion is now case-insensitive. The fix is in the bump commit so that commit builds and passes on its own.
User-visible change from the bump: Savings Plans commitment amount
go 29adce1 changes how
CreateSavingsPlansends the hourly commitment. It used to be rounded to cents (%.2f); it is now truncated to at most 5 decimals, and the allowed range is 0.001 to 1,000,000. For example, 1.239 is now sent as 1.239, not 1.24, and 0.005 as 0.005, not 0.01. Truncation never rounds up, so there is no overspend. The CLI's own precheck runs before dry-run and before the confirmation prompt, without an AWS call. Commit 3 aligns it with the library'sspcommitment.Normalize: it rejects values below 0.001 or above 1e6, NaN and Inf, and no longer rejects 0.001-0.004 with a stale message. The CHANGELOG records this. The purchase-results CSV'sHourlyCommitmentcolumn (cmd/multi_service_csv_details.go:25) is filled from the recommendation afterNormalize, so it now shows the truncated amount that was actually sent, for example 1.23456 instead of 1.2345678.Commits (each <= 400 additions+deletions)
Local verification (macOS, this HEAD)
go build -o cudly ./cmd,go vet ./...,go test ./...and golangci-lint (0 issues) all pass.TestReservationExpiryCommand/replaced-inside-lookbackandTestReservationExpiryCreditsReplacementsInsideLookbackfail with main's old helper and pass after the change.CoverageLookbackDays: 0, the command test and the replaced-inside-lookback and default-lookback subtests fail.Independent reviews follow as PR comments.
🤖 Generated with Claude Code