Repository navigation
fix(azure): set CommitmentCurrency on Azure recommendations #623
Description
What happens
Azure recommendations never set common.Recommendation.CommitmentCurrency. AWS sets it for RIs and Savings Plans (providers/aws/recommendations/parser_ri.go:241, parser_sp.go:277), and so does GCP Compute Engine (providers/gcp/services/computeengine/client.go:1096). No file under providers/azure assigns it (checked on main at 86907ad).
Azure amounts are in fact checked as USD before they are kept. The Consumption path drops a recommendation whose reservation retail price is not USD (providers/azure/internal/recommendations/consumption.go:247), and RequireUSDCode refuses a non-USD currencyCode. The check passes, but the result is not recorded on the recommendation, so downstream it looks like "currency unknown".
Why it matters
The platform is moving to a fail-closed rule for spend caps (LeanerCloud/cloud-commitments-platform#361, implemented by LeanerCloud/cloud-commitments-platform#1296): a user or API key with a USD spend cap is refused any purchase whose commitment currency is not proven to be USD. With no currency on Azure recommendations, every capped Azure purchase is refused once that rule ships. The platform's plan-step cap (max_step_commitment) cannot get the same rule until this is fixed, because applying it would stop every Azure auto-purchase plan. That platform follow-up is tracked separately and depends on this issue.
Where
Places that build Azure recommendations with commitment amounts:
providers/azure/internal/recommendations/consumption.goExpandConsumptionVariants(around line 266): the commitment comes from the Retail Prices reservation price, whichPricer.resolvehas already required to be USD.providers/azure/internal/recommendations/converter.go(around lines 180 and 442, the legacy path): the comment says theAmount.Currencyis discarded. Set the currency here only if the sourceCurrencyis checked to be USD; otherwise leave it empty.providers/azure/services/savingsplans/benefit_recommendations.go(around line 255).- The per-service clients that build a
common.Recommendationdirectly (compute, database, cache, cosmosdb, managedredis, search, synapse), where they carry commitment amounts.
Suggested fix
Set CommitmentCurrency = "USD" only where every required payment leg (upfront and/or recurring) comes from a source whose currency was checked to be USD. Leave it empty anywhere the currency is not proven. That follows the contract in pkg/common/types.go:237-239: there is no USD default and no FX.
Acceptance criteria
- Azure recommendations from the Consumption path and the Savings Plan benefit path carry
CommitmentCurrency == "USD"when their commitment amounts come from a USD-checked source. - A recommendation whose source currency is missing or not USD still has an empty
CommitmentCurrency(or is skipped, as today). It is never labelled USD by default. - Unit tests for each path: a USD source sets the field, a missing currency leaves it empty, and a non-USD source is skipped.
- A tagged release the platform can pin, so the platform's
max_step_commitmentfollow-up can proceed.
Refs LeanerCloud/cloud-commitments-platform#361, LeanerCloud/cloud-commitments-platform#1296, #124, #409.
Filed by IAmJSD's agent at IAmJSD's request (acting owner while the maintainers are away).
Activity
test(azure): pin empty CommitmentCurrency on Advisor and search paths
fix(azure): set CommitmentCurrency on Azure recommendations (LeanerCl…