Repository navigation
fix(aws): credit own replacement RIs in RDS family expiry sizing - #347
Conversation
Cost Explorer coverage is a lookback average, so RIs bought to replace expiring ones are not in it yet. With a partial (single-account) inventory the max(C-E, min(C, A-E)) formula took the C-E branch and re-bought them. Add ApplyFamilyNUSizingRDSWithExpiryOptions: visible active, non-expiring RIs that started inside CoverageLookbackDays (R) are credited, covered = max(0, max(min(C, C-E+R), min(C, A-E))). R = 0 is identical to the merged function, which is unchanged. Refs LeanerCloud/cloud-commitments-cli#2132, #2175 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 3 billable files and costs up to $0.75.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 28 minutes for your next included review. View limit details
Comment |
|
Head moved only by a merge of origin/main (no formula or test changes). Conflict file: CHANGELOG.md (both |
Independent merge-gate review (Opus 5.5, claude-opus-5-5): APPROVEReviewed SHA: What I checked
Non-blocking follow-ups
|
What
ApplyFamilyNUSizingRDSWithExpiry(#341) re-buys replacement RIs the account already bought, when the inventory is partial (the CLI inventory is single-account, cli#2131). Cost Explorer coverage is a lookback average, so RIs started inside the lookback are not in it yet, and theC-Ebranch ofmax(C-E, min(C, A-E))ignores them. Found in the cli#2175 gate (F1): lagged coverage 82.5%, 4 large expiring, 4 replacements bought 2 days ago, 12 other-account large not in the inventory. True gap is 0, the CLI dry run buys 3 x db.r6g.large.Adds
ApplyFamilyNUSizingRDSWithExpiryOptionswithFamilyExpiryOptions{WindowDays, CoverageLookbackDays}. R = NU of visible active, non-expiring RIs in the family that started insideCoverageLookbackDays. Post-expiry covered:max(0, max(min(C, C - E + R), min(C, A - E)))FamilyExpiryReport.ReplacementNUrecords R. Existing exports are unchanged;ApplyFamilyNUSizingRDSWithExpirydelegates with lookback 0, so R = 0 and it is byte-for-byte the merged behaviour. The CLI should pass the lookbackDays it givesGetRICoverageMap.Proof sketch
min(C, C-E+R) >= C-E: covered is never below the merged formula, so the purchase never grows.covered <= C, andC - covered <= E: the deduction never exceeds expiring NU.C-E+R = L+Oth+(1+f)R >= L+Oth+R >= A_all-E_all; if R > E the first term equals C >= the full-inventory value. So covered >= the full-inventory covered, i.e. purchase <= the full-inventory purchase.C-Ebranch can still over-buy against the full inventory (cli#2131).Tests
+rep, flipping the start-date comparison, removing themin(C, .)cap each fail tests.GOWORK=off go test ./...in providers/aws, golangci-lint (go1.26.9) and git-secrets scan clean.Refs LeanerCloud/cloud-commitments-cli#2132, LeanerCloud/cloud-commitments-cli#2175. Follow-up for the EC2 per-pool path: #346.
🤖 Generated with Claude Code