Repository navigation
fix(gcp): fail on missing or mixed SKU currency instead of seeding USD - #239
Conversation
Cloud SQL and Memorystore pricing seeded currency to USD and let each later SKU overwrite it, so a SKU without a currency or with a different one produced a wrongly labelled pair. The currency now comes from the priced SKUs and a missing or conflicting one is an error. Cloud Storage has the same shape and is left to a follow-up because it overlaps #205.
|
@coderabbitai full review |
|
|
Warning Review limit reached
This review includes 6 billable files and costs up to $1.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 10 minutes for your next included review. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Your 57 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (6)
Comment |
What
Cloud SQL (
providers/gcp/services/cloudsql) and Memorystore (providers/gcp/services/memorystore) pricing no longer seed the currency to USD and overwrite it with whichever SKU came last. Each SKU that contributes a price must carry a currency code, and all contributing SKUs must agree; otherwise the lookup returns an error. A consistent non-USD currency is returned as that currency. This follows the policy of the Azure fixes (#179-#187).A small shared helper,
providers/gcp/internal/billingcurrency.Unify, holds the rule and is used by both extractors.Why
Same defect as the Azure half of #102: a missing or conflicting currency silently produced a mislabelled on-demand/commitment pair and a savings percentage computed across denominations.
Source of truth (Cloud Billing Catalog API, google.golang.org/api v0.274.0, cloudbilling/v1/cloudbilling-gen.go)
Money.CurrencyCode("three-letter ISO 4217 code") is per price:type Moneyat :763, field at :765.PricingInfo(:980) ->PricingExpression(:914) ->TierRate(:1231) ->UnitPriceMoney.currencyCode(:3461-3463): "currency code for the pricing info in the response proto ... If not specified USD will be used." So one response is single-currency and conflicting or empty currencies among its SKUs are a data error, not a legitimate case.Behaviour change
Callers of
getSQLPricing/getRedisPricing(and so GetOfferingDetails) now get an error where they previously got a possibly wrong currency label. With no priced SKU, the extractor now returns an empty currency instead of "USD"; both callers already error on a zero on-demand price.Scope
Refs #102, does not close it: the GCP Cloud Storage extractor (
cloudstorage/client.go~256/272) has the same shape but is also changed by open PR #205, so it is left for a follow-up. The Azure half is already on main. No request parameter was changed.Verification
TestGetSQLPricing_CurrencyandTestGetRedisPricing_Currency(fixtures only): consistent EUR returned as EUR, consistent USD, mixed USD/EUR, missing commitment currency, missing on-demand currency.go vet ./...andgo test ./...in providers/gcp pass; golangci-lint (repo config, run from providers/gcp) exit 0, 0 issues.