Repository navigation
fix(azure): cap the savings-plan inventory pager and honor ctx cancellation - #459
Conversation
|
@coderabbitai review |
|
Independent review verdict: CLEAN at 6113015Reviewer: fresh Claude agent (Sonnet, high effort), not the author, cold brief. The PR body was treated as a claim. Coordinator: claude-cc-reviewer. Blocking findings: none. The guard fails closed: hitting the cap never returns a truncated inventory to the duplicate-purchase guard. Verified:
Notes (non-blocking):
What was attacked and how (providers/azure,
Gate: labels are on the PR (no closing issue). Merge once CI is green, after the go PRs ahead of it in the merge queue. |
|
Follow-up on note 1 (checked by claude-cc-reviewer): the only real-money consumer of |
|
CI on |
|
CI is green on head |
170d535 to
787bee2
Compare
|
Correction to my previous comment: the head 787bee2 has one commit beyond the reviewed 6113015. The reviewed commit itself is identical ( |
787bee2 to
d2cd02f
Compare
…lation GetExistingCommitments looped on pager.More() with no page cap and no ctx.Err() check, so a pager that never terminates spun forever and a cancelled context was only noticed by the SDK call. Mirror the #251 pattern (per-package const, inline check): check ctx.Err() each page and return a wrapped error after maxSavingsPlanPages (100), never partial results. Tests live in client_pager_cap_test.go: endless pager hits the cap, a ctx cancelled mid-walk or before the first page stops it, a multi-page listing returns everything, and exactly the cap still succeeds. Closes #247 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #247 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d2cd02f to
1425af9
Compare
Summary
#251 capped four of the five uncapped Azure pager loops. The fifth was
GetExistingCommitmentsinproviders/azure/services/savingsplans/client.go. It looped onpager.More()with no page cap and noctx.Err()check, so a pager that never ends spun forever, and a cancelled context was only noticed inside the SDK call.The fix mirrors #251's pattern: a per-package constant and an inline check, with the same error wording.
maxSavingsPlanPages = 100. That is the same value as fix(azure): cap the remaining Azure pager walks #251'smaxSubscriptionPages, and more headroom than its 20 and 50 caps. Savings plans are listed per billing scope, so real volumes are small, and the cap only stops a runaway pager.ctx.Err()first and returns a wrapped "context canceled during pagination" error.Tests are in a new file,
client_pager_cap_test.go. Open PR #453 ownsclient_test.goin this package, so the new file avoids touching it. It uses a small multi-page fake, because the existingmockListAllPageronly serves one page. Five cases:context.Canceled.Closes #247
Verification (macOS, Go 1.26.9)
(cd providers/azure && GOWORK=off go test -race -short ./...)passes.make buildandmake vetpass.GetExistingCommitments.client.go.>=cap comparison, and returning the partial slice on the cap or ctx error each fail the test.Fake pager only; no Azure call.
🤖 Generated with Claude Code
Summary by CodeRabbit