Skip to content

fix(azure): cap and cancel-check the eight remaining pager loops - #246

Merged
cristim merged 4 commits into
mainfrom
fix/azure-pager-caps-93
Oct 6, 2026
Merged

cristim merged 4 commits into
mainfrom
fix/azure-pager-caps-93

Conversation

@cristim

@cristim cristim commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

What

Adds the page cap and ctx.Err() check the sibling loops already use to the eight pager loops listed in #93:

  • cache fetchSKUCatalogue (cap maxCachesPages)
  • cosmosdb fetchDominantAPIType (cap maxAccountsPages)
  • database walkManagedInstances and hasRegularServers (new maxSQLListPages = 20)
  • managedredis GetExistingCommitments (new maxReservationsPages = 50)
  • synapse GetRecommendations and collectSynapseReservations (new maxRecsPages, maxReservationsPages)
  • compute collectExchangeableReservations (existing maxReservationsPages)

Behaviour change

  • Loops that already returned errors (managedredis, synapse, exchange) now return a cap error or the wrapped context error instead of walking on. The exchange ownership listing no longer spins on an endless pager.
  • Four loops log and return a degraded value by design (SKU catalogue, Cosmos API type, SQL walks). They keep that contract: on cap or cancel they log (cap case names the service and cap) and return the same failure value as a page error; walkManagedInstances returns complete=false, as in fix(azure): leave AZConfig and Deployment empty on a managed-instance page error #240.

How verified

Fake pagers report More() for 1000 pages. Each loop has a cap test (calls stop at the cap) and a cancelled-context test (zero NextPage calls). Normal multi-page behaviour stays covered by the existing tests. Pre-fix the compute tests fail ("An error is expected but got nil", cancel error nil); removing the cap in the cosmosdb loop fails its test (expected 20, actual 1000). go vet ./..., go test ./... and golangci-lint run ./... pass in providers/azure (exit 0).

hasRegularServers now returns (found, complete); fetchServerInfo blanks AZConfig and Deployment when the server walk is incomplete (cap, cancel, page error), so an incomplete walk no longer reads as "no servers" and yields Deployment "managed".

Follow-ups (not in this PR)

Loops with the same shape: managedredis/client.go ~427 (collectSKUsFromPager), savingsplans/client.go ~155, provider.go ~478 (locations), accounts_cache.go ~212 (subscriptions), recommendations.go ~345 (Advisor), plus the two loops in #103. serverInfoOnce caching a cancelled first fetch is pre-existing and tracked in #241.

Closes #93

Eight pager loops in cache, cosmosdb, database, managedredis, synapse and compute/exchange had no page cap and no ctx.Err() check, unlike their siblings. A cancelled context or an endless pager now stops the walk: loops that return errors report the cap or the context error; the log-and-degrade loops (SKU catalogue, Cosmos API type, SQL server and managed-instance walks) log and return their existing failure value.

Closes #93
@cristim cristim added priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged urgency/this-quarter Within the quarter impact/few Limited audience effort/s Hours type/bug Defect labels Oct 6, 2026
@cristim

cristim commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 12 billable files and costs up to $3.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 13 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: c94cf744-ff88-473d-873a-339d3a4ddd55
📥 Commits

Reviewing files that changed from the base of the PR and between 4a7fac7 and 24caa60.

📒 Files selected for processing (12)
  • providers/azure/services/cache/client.go
  • providers/azure/services/cache/pagination_cap_test.go
  • providers/azure/services/compute/exchange.go
  • providers/azure/services/compute/exchange_pagination_cap_test.go
  • providers/azure/services/cosmosdb/client.go
  • providers/azure/services/cosmosdb/pagination_cap_test.go
  • providers/azure/services/database/client.go
  • providers/azure/services/database/pagination_cap_test.go
  • providers/azure/services/managedredis/client.go
  • providers/azure/services/managedredis/pagination_cap_test.go
  • providers/azure/services/synapse/client.go
  • providers/azure/services/synapse/pagination_cap_test.go
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. Your current included review allowance is based on your included PR review attempts over the past 7 days. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 25 minutes.

Extract the per-page bodies of fetchSKUCatalogue, synapse GetRecommendations and walkManagedInstances so each stays at or below 10.
hasRegularServers now returns (found, complete); fetchServerInfo blanks AZConfig and Deployment when the server walk was cut short by the page cap, cancellation or a page error. Also extracts tallyManagedInstances to keep walkManagedInstances under the cyclomatic limit.
Assert exactly cap pages succeed and cap+1 fails at cap calls, and add cancel-mid-walk cases for compute exchange and managedredis.
@cristim cristim changed the title fix(azure): cap and cancel-check the remaining pager loops fix(azure): cap and cancel-check the eight remaining pager loops Oct 6, 2026
@cristim
cristim merged commit 8dab581 into main Oct 6, 2026
15 checks passed
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-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(azure): eight pager loops have no page cap and no context check

1 participant