Skip to content

fix(aws): paginate CE recommendations + RDS engine versions (closes #692) - #693

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/692-paginate-ce-recs
May 22, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/692-paginate-ce-recs

Conversation

@cristim

@cristim cristim commented May 22, 2026

Copy link
Copy Markdown
Member

Summary

Three AWS API calls silently read only page 1 of their result sets, causing CUDly to emit partial RI/SP recommendations and incomplete RDS engine-version metadata for customers with large payer accounts (closes #692).

Site 1 -- providers/aws/recommendations/client.go (GetReservationPurchaseRecommendation)

  • Before: single SDK call inside rate-limiter retry loop; result.NextPageToken never read.
  • After: outer pagination loop (fetchRIAllPages) drives NextPageToken; rate-limiter retry (fetchRIPageWithRetry) is the inner loop per-page.

Site 2 -- providers/aws/recommendations/parser_sp.go (GetSavingsPlansPurchaseRecommendation)

  • Before: single SDK call per plan type inside rate-limiter retry loop; result.NextPageToken never read.
  • After: fetchSPAllPages drives pagination per plan type; fetchSPPageWithRetry is the inner loop. Outer for planType loop unchanged.

Site 3 -- cmd/multi_service_engine_versions.go (DescribeDBMajorEngineVersions)

  • Before: one call per engine; output.Marker never read.
  • After: fetchMajorEngineVersionsForEngine paginates via Marker; queryMajorEngineVersionsWithClient is extracted for testability; parseDBMajorEngineVersion extracted for gocyclo relief.

All three sites share the same contract:

Test plan

  • 3 new tests per site: multi-page accumulation (3 pages, N+M+K items), empty-token terminator (1 call only), pagination-cap error.
  • TestGetRecommendations_ContextCancellation updated: pre-cancelled ctx now returns context.Canceled directly (ctx.Err() fires before rate-limiter, which is correct).
  • 1020 tests pass across providers/aws/recommendations/... and cmd/....
  • gocyclo -over 10 clean on all modified files.

Closes #692
Refs #688 #691 PR #690

)

GetReservationPurchaseRecommendation, GetSavingsPlansPurchaseRecommendation,
and DescribeDBMajorEngineVersions each silently discarded every page after
the first. For large payer accounts, CE returns recommendations across
multiple pages, so callers were seeing a fraction of the real result set.

All three call sites now drive a token-driven pagination loop. The existing
rate-limiter retry loop stays as the inner (per-page) loop. ctx.Err() is
checked at the top of each iteration (feedback_ctx_cancel_terminal). The
loop terminates on nil OR empty-string token (PR #690 parity). Exceeding
maxRecommendationPages/maxEngineVersionPages = 20 returns a diagnostic
error citing the service and issue #692. gocyclo relief: fetchSPAllPages +
fetchSPPageWithRetry extracted for SP; queryMajorEngineVersionsWithClient +
fetchMajorEngineVersionsForEngine extracted for RDS (all stay under cap 15).

Three new test groups: multi-page accumulation (3 pages), empty-token
terminal (no extra call), and pagination cap error. Updated
TestGetRecommendations_ContextCancellation to assert context.Canceled
directly -- the new ctx.Err() guard at the top of the pagination loop fires
before the rate-limiter so the error path changed correctly.
@cristim cristim added triaged Item has been triaged priority/p1 Next up; this sprint severity/high Significant harm urgency/now Drop other things impact/all-users Affects every user effort/s Hours type/bug Defect labels May 22, 2026
@cristim

cristim commented May 22, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 2 reviews/hour. Refill in 18 minutes and 9 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b98c871e-077a-454f-9e45-8ac3ce52ad2c

📥 Commits

Reviewing files that changed from the base of the PR and between b581fe7 and 4d5a816.

📒 Files selected for processing (6)
  • cmd/multi_service_engine_versions.go
  • cmd/multi_service_engine_versions_paginate_test.go
  • providers/aws/recommendations/client.go
  • providers/aws/recommendations/client_test.go
  • providers/aws/recommendations/parser_sp.go
  • providers/aws/recommendations/parser_sp_additional_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/692-paginate-ce-recs

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

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 22, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit 423e87c into feat/multicloud-web-frontend May 22, 2026
4 checks passed
@cristim
cristim deleted the fix/692-paginate-ce-recs branch May 22, 2026 22:42
cristim added a commit that referenced this pull request Sep 27, 2026
) (#693)

GetReservationPurchaseRecommendation, GetSavingsPlansPurchaseRecommendation,
and DescribeDBMajorEngineVersions each silently discarded every page after
the first. For large payer accounts, CE returns recommendations across
multiple pages, so callers were seeing a fraction of the real result set.

All three call sites now drive a token-driven pagination loop. The existing
rate-limiter retry loop stays as the inner (per-page) loop. ctx.Err() is
checked at the top of each iteration (feedback_ctx_cancel_terminal). The
loop terminates on nil OR empty-string token (PR #690 parity). Exceeding
maxRecommendationPages/maxEngineVersionPages = 20 returns a diagnostic
error citing the service and issue #692. gocyclo relief: fetchSPAllPages +
fetchSPPageWithRetry extracted for SP; queryMajorEngineVersionsWithClient +
fetchMajorEngineVersionsForEngine extracted for RDS (all stay under cap 15).

Three new test groups: multi-page accumulation (3 pages), empty-token
terminal (no extra call), and pagination cap error. Updated
TestGetRecommendations_ContextCancellation to assert context.Canceled
directly -- the new ctx.Err() guard at the top of the pagination loop fires
before the rate-limiter so the error path changed correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/all-users Affects every user priority/p1 Next up; this sprint severity/high Significant harm triaged Item has been triaged type/bug Defect urgency/now Drop other things

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant