Repository navigation
fix(cmd): discover recommendation regions from Cost Explorer - #2194
Conversation
fetchRecommendationsForRegion logged provider errors and returned nil, and fetchAllRecs logged region-discovery failures and continued, so an expired session or denied Cost Explorer call read as "Nothing to purchase" with exit 0. Both now return the error and the run exits 1. Empty answers and incomplete-but-usable answers keep their current behaviour. Refs #2190 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Region iteration used ec2:DescribeRegions, which lists only the caller's opted-in regions. Cost Explorer returns linked-account recommendations in regions the caller has not opted into, so a default run dropped them (25 recommendations from the API, 23 from the CLI on a live payer). The regions now come from the recommendations for the run's term, payment option and lookback. DescribeRegions is no longer called for them. Refs #2189 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 7 billable files and costs up to $1.75.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 22 minutes for your next included review. View limit details
Comment |
|
Independent review (claude-opus-5-5) of e543c34: APPROVE Reviewed against its base What changed, checked against the code
Verification
Cost Explorer call costThe library filters by region on the client side ( Non-blocking findings
CI on e543c34: only CodeRabbit has run (pass). The main workflows have not run on this stacked base, so CI needs to run after the PR is retargeted to main. |
# Conflicts: # cmd/recommendation_completeness_test.go
|
Independent review (claude-opus-5-5) of bde52f9: APPROVE This re-verifies the PR after the retarget to main. My earlier approval was of e543c34. Delta from e543c34
Verification at bde52f9
CINo GitHub Actions workflow has run on bde52f9: The earlier non-blocking findings still apply: the |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Independent review (claude-opus-5-5) of 52b3b13: APPROVE This re-verifies the PR after the lint fixes. I last approved bde52f9.
|
Closes #2189
Stacked on #2192 (base branch
fix/2190-fetch-fail-loud): both change the region/fetch path and the completeness harness. Retarget tomainonce #2192 merges; until then the diff against main also shows #2192's commit.What
For non-Savings-Plan services, a run without
--regionsiteratedec2:DescribeRegions(the caller's opted-in regions). Cost Explorer also returns linked-account recommendations in regions the payer has not opted into, and the per-region filter never saw them.discoverRegionsForServicenow derives the regions from the Cost Explorer recommendations for the run's term, payment option and lookback (one extra Cost Explorer call per service), reusingfetchRecommendationsForRegionso incomplete and error handling is the same as the per-region fetch.determineRegionsForServicetakesConfiginstead ofaws.Config+ regions, andhandleRegionDiscoveryError(the DescribeRegions-failure fallback) is gone.--regionsbehaviour is unchanged.Not touched: the existing-RI coverage fetch for
--target-coveragestill lists regions withgetAllAWSRegions(fetchExistingCoverage). The per-region fetch repeating the account-wide Cost Explorer call (efficiency) is the architect's item.Tests
TestDetermineRegionsForService_DiscoversRegionsTheCallerHasNotOptedIntoandTestFetchAllRecs_DefaultRunKeepsRecommendationsInRegionsOutsideTheCallersOptInsuseaws.Config{}with no credentials, so any DescribeRegions call would fail; on the old code they hit the DescribeRegions path.TestDetermineRegionsForService_CanceledContextIsTerminalreplaces thehandleRegionDiscoveryErrorcancel test.fallbackregion mode (no DescribeRegions any more) and now expects 1 Cost Explorer call for discovery plus 1 per discovered region, and zero DescribeRegions calls.go vet ./cmdandgo test ./cmdpass (skippingTestQueryMajorEngineVersions_ErrorHandling, which hangs locally this session independent of this change). golangci-lint panics locally on this toolchain; pre-commit hooks pass.Live dry run (read-only), shift-prd (payer )
cudly --services ec2 --term 1 --payment no-upfront --rec-lookback-period 30d --coverage 100(no--regions).Raw API,
aws ce get-reservation-purchase-recommendation ... ONE_YEAR NO_UPFRONT THIRTY_DAYS LINKED: 25 recommendations (London 11, N. Virginia 7, Frankfurt 4, Zurich 2, Cape Town 1... per CE region name).before (main 8ddb891):
Found N recommendationssummed over 23 regions = 23, no eu-central-2.after: 5 regions discovered, 25 found, including
(= $102.27/mo, the missing amount from the audit).
🤖 Generated with Claude Code