Skip to content

fix(azure): set CommitmentCurrency on Azure recommendations #623

Closed

Description

@IAmJSD

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.go ExpandConsumptionVariants (around line 266): the commitment comes from the Retail Prices reservation price, which Pricer.resolve has already required to be USD.
  • providers/azure/internal/recommendations/converter.go (around lines 180 and 442, the legacy path): the comment says the Amount.Currency is discarded. Set the currency here only if the source Currency is 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.Recommendation directly (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_commitment follow-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

  1. added a commit that references this issue on Oct 26, 2026
    321cc98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions