Repository navigation
Conversation
The Cloud SQL, Memorystore and Cloud Storage extractors read only TieredRates[0], so a SKU whose first tier is a free allowance and whose later tier is paid came back as price 0 and was skipped entirely. Add skumatch.PaidRate, which returns the first tier with a non-zero unit price, and use it in all three extractors. SKUs whose tiers are all free are still skipped. Closes LeanerCloud#242 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
Member
|
Independent adversarial review: CLEAN at
Still needed before merge: owner approval of the fork CI runs and green CI on this SHA, and the author marking the PR ready. Labels mirrored from #242. CR skipped: quota/draft; the merge comment will carry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
extractSQLPriceFromSKU(Cloud SQL),extractPriceFromSKU(Memorystore) andextractStoragePriceFromSKU(Cloud Storage) priced a SKU fromTieredRates[0]only. A SKU whose first tier is a free allowance ([0, >0]) came back as price0, and theprice == 0 → continueguard in eachextract*PricingFromSKUsloop then dropped it, so the region/tier got no price instead of the paid one.Fix
skumatch.PaidRate(*cloudbilling.PricingExpression) *cloudbilling.TierRatereturns the first tier with a non-zero unit price (skipping nil tiers and tiers with noUnitPrice), ornilwhen every tier is free.TieredRates[0]. Everything after that (nanos math, Cloud Storage unit conversion, currency, slot) is unchanged.StartUsageAmount, and a workload large enough to need a commitment is past the free allowance, so the first paid tier is the rate it pays at the margin. This is a documented assumption. I did not check the live Billing Catalog for a real Cloud SQL or Memorystore SKU shaped like this, and I made no GCP API calls.Closes #242
Verification
All of this is unit/fixture evidence built from hand-written
cloudbilling.Skuvalues. No real GCP catalog data was used.Fail-before (new tests run on
main's extractors, before the fix):(
TestPaidRatetests the new helper, and theAllTiersFreetests are guards that pass before and after the fix.)Pass-after, run from
providers/gcp:I set
AWS_CONFIG_FILE/AWS_SHARED_CREDENTIALS_FILEto/dev/nullonly because the local machine's default AWS profile is invalid. The GCP tests don't depend on it.Mutation check: if
PaidRategoes back to returningTieredRates[0], the threeFreeFirstTierUsesPaidTiertests and thefree first tier then paidcases inTestPaidRatefail.Interaction with #424 (
fix/issue-243)#424 also edits
providers/gcp/services/cloudstorage/client.go, inextractStoragePricingFromSKUscurrency handling and the import block. This PR changes only theTieredRates[0]lines inextractStoragePriceFromSKU, adds no import there (skumatchis already imported), and puts its test in a newtiered_rates_test.goinstead of #424'spricing_currency_test.go. A trial merge offork/fix/issue-243into this branch auto-merged with no conflicts, andgo build ./...plus thecloudstorage/skumatchtests passed on the merged tree.Out of scope
providers/gcp/services/computeengine/pricing.go:259also reads onlyTieredRates[0]. The issue doesn't list it, so I left it alone. It could switch toskumatch.PaidRatein a follow-up.[0, >0]tier shape.Maintainer: please copy the issue's triage labels onto this PR:
triaged,priority/p3,severity/low,urgency/eventually,impact/few,effort/s,type/bug.🤖 Generated with Claude Code