Problem
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 / hours
CommitmentPrice: commitmentPrice, // wrong: per-hour, not term total
OnDemandPrice: onDemandPrice * hoursInTerm, // correct: term total
...
}
Fix
Mirror the fix applied to Memorystore and Cloud Storage in PR #1047:
commitmentPriceTerm := commitmentPrice * hoursInTerm
savingsPercentage := calculateSQLSavingsPercentage(onDemandPrice, hoursInTerm, commitmentPriceTerm)
return &SQLPricing{
HourlyRate: commitmentPrice, // per-hour rate
CommitmentPrice: commitmentPriceTerm, // term total
OnDemandPrice: onDemandPrice * hoursInTerm,
...
}
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.
Problem
getSQLPricinginproviders/gcp/services/cloudsql/client.gohas the same per-unit vs term-total mismatch that was fixed for Memorystore and Cloud Storage in PR #1047.The
extractSQLPricingFromSKUs/extractSQLPriceFromSKUfunctions return a raw per-hour SKU price, but the code passes it directly tocalculateSQLSavingsPercentage(onDemandPrice, hoursInTerm, commitmentPrice)which compares it against the term totalonDemandPrice * hoursInTerm. This produces a savings percentage close to 100% instead of a realistic ~30%.Additionally,
HourlyRate = commitmentPrice / hoursInTermdivides an already-per-hour price by hours, yielding a near-zero rate.Affected block (lines ~347-356):
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.