Skip to content

fix(gcp): avoid double counting monthly commitment costs - #408

Merged
cristim merged 1 commit into
mainfrom
fix/gcp-monthly-commitment-cost
Oct 15, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/gcp-monthly-commitment-cost

Conversation

@cristim

@cristim cristim commented Oct 15, 2026

Copy link
Copy Markdown
Member

Cloud SQL and Memorystore monthly CUD recommendations put the catalog term total in the upfront field and also emitted monthly charges. A catalog total near 1200 therefore became about 2400 in the platform's full-term commitment. A term-total-derived break-even override also caused no-upfront recommendations to be filtered out.

Derive recurring monthly charges directly from the positive catalog total and leave upfront cost and the override zero. Preserve offering totals and unknown recurring prices on catalog failure. This follows the existing Compute Engine contract.

Closes #391
Refs #399

Validation on 83f0fb40c0ffe9f91fc30ff584a9315558a7e305 (tree 53bc13f0ff247e620d6afcbde27a0b0b51a98d05):

  • Two retained implementation review passes plus two fresh cold adversarial passes, with two exact-head rebase transfer passes; no unresolved findings. The rebased four-file diff is byte-identical to the originally reviewed change.
  • Independent fake Billing and Recommender responses through public GetRecommendations, serialized into the actual platform scheduler converter and RecommendationRecord.TotalCommitment: parent fails near 2400 / 7200, fixed passes near 1200 / 3600 for one / three years. Default, monthly and no-upfront aliases and aggregate count resizing 3 to 2 covered.
  • Break-even, scorer filtering, reporter upfront output, offering totals, missing / negative pricing, and pointer-safe scaling checked. Separate scratch mutations restoring a positive break-even override and removing the positive-price guard fail the regressions.
  • Standalone GCP full short race suite, fresh build and official golangci-lint 2.10.1 pass with Go 1.26.9 and GOWORK=off. Fresh affected-service race tests pass after rebasing onto merged feat(ladder): expose scoped EC2 commitment rates #404. Normal local commit hooks passed, including tidy, vet, security and complexity checks.

All subsequent local test and hook commands disable ambient cloud credentials; new tests inject billing fixtures. Evidence is synthetic SDK/catalog data exercising production functions, with no live purchase or deployment. Three-year tests cover current cashflow arithmetic, not independent term-specific vendor price acceptance. Aggregate count is seeded for the shared resizing path.

Remaining OnDemandCost term-basis and savings Duration work stays in #399. Separate follow-ups: #406 for existing fixture tests using ambient ADC, #407 for unsupported payment-label normalization. No unrelated calculation or module pin changes. Added comments: 2 / 136 lines (1.5%).

Derive monthly charges directly from catalog term totals and preserve
zero upfront cost and break-even for Cloud SQL and Memorystore CUDs.
Keep offering totals and unknown recurring pricing intact.
@cristim cristim added priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/few Limited audience effort/s Hours type/bug Defect triaged Item has been triaged labels Oct 15, 2026
@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 4 billable files and costs up to $1.00.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 6 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 61 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-go/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 928013c3-9055-4c5c-ad96-3c787b73bfbc
📥 Commits

Reviewing files that changed from the base of the PR and between 9511dcf and 83f0fb4.

📒 Files selected for processing: 4
  • providers/gcp/services/cloudsql/client.go
  • providers/gcp/services/cloudsql/client_test.go
  • providers/gcp/services/memorystore/client.go
  • providers/gcp/services/memorystore/client_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@cristim

cristim commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review and local verification cover exact head 83f0fb40c0ffe9f91fc30ff584a9315558a7e305, tree 53bc13f0ff247e620d6afcbde27a0b0b51a98d05, base 9511dcfbdcb1aa9eac8081b54b6a648434580496.

Two retained cold passes found no actionable findings. The reviewer attacked the public producer path, catalog validity, term division, payment aliases, independent offering totals, zero-upfront break-even, scorer/reporter behavior, count scaling, published dependency isolation and regression strength. Original parent and separate scratch mutations fail by runtime assertions. After rebase, the reviewer verified identical change bytes and unchanged affected dependencies, then reran public producer fixtures and the actual platform handoff at the new head.

The actual platform scheduler converter and TotalCommitment processed serialized producer results: parent totals 2399.99999352 and 7199.99998056, fixed totals 1199.99999676 and 3599.99999028; nanos precision explains the tolerance. Count 3 to 2 uses the real shared resizing helper. No copied converter or total formula was used in this independent check.

Commands passed: standalone GOWORK=off GOTOOLCHAIN=go1.26.9 go test -count=1 -race -short ./..., go build ./..., and official go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.10.1 run --timeout=5m ./.... Fresh affected-service race tests also pass at this rebased SHA. Local normal commit hooks passed. Fixture tests and hooks explicitly disable ambient ADC.

Limitations: realistic synthetic Billing/Recommender fixtures, no live cloud economics or real-account acceptance; three-year arithmetic uses the existing SKU selection. The change preserves valid offering totals and unknown recurring pricing. Follow-up isolation, normalization and on-demand/savings work remains linked in #406, #407 and #399.

Review is satisfied by independent exact-revision verification under the repository review gate. CodeRabbit has not been manually triggered for this PR; any automatic findings will still be checked and resolved. CI must be green on this exact SHA before merge.

@cristim

cristim commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

CodeRabbit automatic processing reported Review limit reached on this exact head and posted no review or inline findings. Its check is not evidence of a completed review. No manual paid review or quota retry was requested. The independent exact-revision review and local verification above cover the change under the repository review gate; merge remains blocked until CI is green on 83f0fb4.

@cristim

cristim commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Final gate: exact reviewed head 83f0fb4, base 9511dcf, live CLEAN / MERGEABLE, zero review threads. All CI is green, including required CI Success and Run pre-commit hooks. Build/test workflow 38704321429 and pre-commit 38704321502 both completed SUCCESS; their independent background watchers terminated successfully. Independent two-pass review and actual producer-to-platform verification evidence is recorded above.

CR waived: quota, adversarial review + local verification + green CI

The automatic quota check performed no review. No manual paid review, quota trigger, or protection bypass is used. This PR is tracked for retrospective CodeRabbit review when quota returns; any actionable finding belongs in a follow-up PR. Follow-up issues filed: #406 and #407; remaining OnDemandCost and savings Duration normalization stays in #399.

@cristim
cristim merged commit a3fb251 into main Oct 15, 2026
15 checks passed
@cristim

cristim commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Merged PR #408 normally at main a3fb25103204341399c624a0ce7b242fc89d3b15 after all PR CI passed at the independently reviewed head 83f0fb40c0ffe9f91fc30ff584a9315558a7e305. The merged tree is exactly the reviewed tree 53bc13f0ff247e620d6afcbde27a0b0b51a98d05.

Post-merge consumer verification: the public GCP module resolves as github.com/LeanerCloud/cloud-commitments-go/providers/gcp@v0.0.0-20261015082501-a3fb25103204. Its go mod download origin matches the merge SHA. From the downloaded module, standalone GOWORK=off GOTOOLCHAIN=go1.26.9 go build ./... and the two services' recurring-cashflow regression tests with -count=1 -race pass. Actual shared dependency resolves to published pkg@v0.0.0-20261013221254-77bc8a993eb8, without workspace substitution.

Together with the independent parent RED / fixed GREEN through public producers and the actual platform scheduler converter plus TotalCommitment, this verifies the reported amount and false-break-even defect. Catalog near 1200 now yields zero upfront, monthly near 100 and full-term spend near 1200; three-year and count-resize cases pass. Valid offering totals remain unchanged, failed/negative catalog recurring prices remain unknown.

Evidence uses realistic local SDK/catalog fixtures exercising production functions; ambient cloud credentials are disabled. No live economic acceptance, purchase or deployment is claimed. Recommendation: #391 is resolved by this merged fix. Follow-up issues filed: #406 for existing test credential isolation, #407 for payment-label normalization; #399 retains OnDemandCost and savings Duration normalization.

Post-merge main CI build/test run 38705503777 and pre-commit run 38705503654 have their own active background watchers. Any main-CI failure will be investigated separately; PR CI was green before merge.

@cristim

cristim commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Post-merge main verification is now terminal green at a3fb251: CI build/test run 38705503777 and pre-commit run 38705503654 both completed SUCCESS. Both main-run watchers and all earlier PR/merge watchers are reaped. Published standalone module build and fixture regression results remain recorded above; owner-safe merged worktree plus local/remote feature branch cleanup is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/few Limited audience priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(gcp/cloudsql,memorystore): BreakEvenMonths treats the term total of a monthly CUD as upfront

1 participant