You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(gcp/cloudsql): commitment price unit mismatch in getSQLPricing #1078
getSQLPricing in providers/gcp/services/cloudsql/client.go has the same per-unit vs term-total mismatch that was fixed for Memorystore and Cloud Storage in PR #1047.
The extractSQLPricingFromSKUs / extractSQLPriceFromSKU functions return a raw per-hour SKU price, but the code passes it directly to calculateSQLSavingsPercentage(onDemandPrice, hoursInTerm, commitmentPrice) which compares it against the term total onDemandPrice * hoursInTerm. This produces a savings percentage close to 100% instead of a realistic ~30%.
Additionally, HourlyRate = commitmentPrice / hoursInTerm divides an already-per-hour price by hours, yielding a near-zero rate.
Affected block (lines ~347-356):
hoursInTerm:=8760.0*float64(termYears)
savingsPercentage:=calculateSQLSavingsPercentage(onDemandPrice, hoursInTerm, commitmentPrice)
return&SQLPricing{
HourlyRate: commitmentPrice/hoursInTerm, // wrong: per-hour / hoursCommitmentPrice: commitmentPrice, // wrong: per-hour, not term totalOnDemandPrice: onDemandPrice*hoursInTerm, // correct: term total...
}
Fix
Mirror the fix applied to Memorystore and Cloud Storage in PR #1047:
Include a regression test that fails pre-fix (SavingsPercentage is ~99.99%) and passes after.
Context
Identified during PR #1047 CR review. The Memorystore and Cloud Storage variants were fixed in #1047. CloudSQL was not flagged by CR but has the identical issue.
Activity
fix(gcp): address CR post-commit findings on payment option, term, an…
fix(gcp/cloudsql): correct savings unit, term propagation (closes #1078)
fix(gcp): wire Count/pricing into GCP converters; refuse fabricated p…