Skip to content

refactor(aws/recommendations): extract generic fetchWithRetry for CE page fetchers - #607

Merged
cristim merged 3 commits into
mainfrom
refactor/120-fetch-with-retry
Oct 20, 2026
Merged

cristim merged 3 commits into
mainfrom
refactor/120-fetch-with-retry

Conversation

@cristim

@cristim cristim commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Part of #120.

What

Extracts a generic fetchWithRetry helper in providers/aws/recommendations and routes fetchCoveragePage, fetchUtilizationPage, fetchSPCoveragePage and fetchSPUtilizationPage through it. Behaviour and error messages are unchanged; four unit tests cover retry-then-success, terminal-error wrapping, max-retries and a canceled context.

Already done on main

Remaining slices of #120

  • Re-measure the per-linter finding count for providers/aws with the CI-pinned golangci-lint and record the breakdown.
  • Burn down any remaining findings per linter, no blanket nolint.
  • Optionally fold fetchRIPageWithRetry, fetchSPPageWithRetry and fetchOnDemandPage into the same helper (they differ in error text and retry-count reporting).

Verified with and without GOWORK=off: build, vet, go test -count=1 ./..., golangci-lint (0 issues).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Changed
    • AWS Cost Explorer coverage and utilization data retrieval now applies consistent rate limiting, concurrency control, and retry handling.
    • Throttling-related failures can recover automatically within the configured retry limit.
    • Terminal errors and canceled requests continue to be reported consistently, with no intended change to existing behavior or error messages.
  • Tests
    • Added coverage for retry recovery, retry limits, terminal errors, and canceled requests.

…page fetchers

fetchCoveragePage, fetchUtilizationPage, fetchSPCoveragePage and
fetchSPUtilizationPage were four copies of the same rate-limit, concurrency
and retry loop. They now delegate to one generic helper with unchanged
behaviour and error messages.

Part of #120.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

  • Run on-demand review

This review includes 6 billable files and costs up to $1.50.

  • 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 17 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 88 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: 5ab09f19-5a43-4748-97cf-ae0d352a5280
📥 Commits

Reviewing files that changed from the base of the PR and between 9b3029e and 573985d.

📒 Files selected for processing: 6
  • CHANGELOG.md
  • providers/aws/recommendations/coverage.go
  • providers/aws/recommendations/fetch_retry.go
  • providers/aws/recommendations/fetch_retry_test.go
  • providers/aws/recommendations/sp_coverage.go
  • providers/aws/recommendations/utilization.go

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-go/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: bbd39cc7-0479-45f6-b3c7-4bfe9254cc21
📥 Commits

Reviewing files that changed from the base of the PR and between 9923440 and 9b3029e.

📒 Files selected for processing: 6
  • CHANGELOG.md
  • providers/aws/recommendations/coverage.go
  • providers/aws/recommendations/fetch_retry.go
  • providers/aws/recommendations/fetch_retry_test.go
  • providers/aws/recommendations/sp_coverage.go
  • providers/aws/recommendations/utilization.go

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

📝 Walkthrough

Four AWS recommendations fetchers now use a shared helper for Cost Explorer rate limiting, concurrency control, and retry handling. Tests cover retry and error behavior. The changelog records the consolidation and states that behavior and error messages remain unchanged.

Changes: AWS Cost Explorer fetch handling

Layer / File(s) Summary
Shared retry helper and tests
providers/aws/recommendations/fetch_retry.go, providers/aws/recommendations/fetch_retry_test.go
fetchWithRetry coordinates rate-limiter waits, concurrency acquisition, SDK calls, and retries. Tests cover recovery after throttling, terminal errors, retry limits, and canceled contexts.
Fetcher integration
providers/aws/recommendations/coverage.go, providers/aws/recommendations/utilization.go, providers/aws/recommendations/sp_coverage.go, CHANGELOG.md
The coverage and utilization fetchers delegate rate limiting, concurrency, and retry handling to fetchWithRetry. The changelog records the consolidation and unchanged behavior and error messages.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 9b302

No concrete issue remains that would prevent merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main refactor: extracting the generic fetchWithRetry helper for AWS Cost Explorer page fetchers.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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 20, 2026

Copy link
Copy Markdown
Member Author

Merge gate verdict (claude-cc-libs)

Every gate holds at head 573985d:

  • Two independent reviews approve the reviewed head 57a8d54. The branch was then updated from main, and the PR diff is byte-identical to the reviewed diff (compared mechanically).
  • CI is green on 573985d, which is the reviewed change on top of current main.
  • 0 unresolved threads; MERGEABLE/CLEAN.

CodeRabbit is waived as a merge gate under the 2026-10-19 decision. Squash-merging.

@cristim
cristim merged commit ca53ccb into main Oct 20, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant