Repository navigation
fix(azure): bound concurrency in the multi-subscription recommendation fan-out - #513
Conversation
|
@coderabbitai review |
|
|
Independent review: CLEAN at The non-test diff adds one What I attacked:
Evidence (macOS, exact SHA; fakes, no Azure call):
Labels mirror #58. CodeRabbit posted a summary. If it has not fully reviewed by merge time: CR waived: quota, adversarial review + local verification + green CI. |
…n fan-out The per-subscription errgroup in MultiSubscriptionRecommendationsClient had no limit, so a tenant with many subscriptions issued unbounded concurrent Azure calls. Cap it with g.SetLimit(concurrency.MaxParallelismFromEnv()) (CUDLY_MAX_PARALLELISM, default 20), the same setting the shared semaphore uses. This is an errgroup limit, not a second semaphore. The shared semaphore is acquired only inside each subscription client's leaf calls and never held across this fan-out, so the two bounds cannot deadlock. Adds a peak in-flight test with 24 subscriptions and a limit of 3. Closes #58 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dcf1585 to
1940dfa
Compare
Merge gate: independent review + local verification (reviewed SHA
|
Summary
MultiSubscriptionRecommendationsClient.GetRecommendations(providers/azure/recommendations_multi_subscription.go) fanned out one goroutine per subscription with an unbounded errgroup, so a tenant with many subscriptions launched every subscription's collection at once. It now callsg.SetLimit(concurrency.MaxParallelismFromEnv())(CUDLY_MAX_PARALLELISM, default 20, the same setting the rest of the collection tree uses).This is an errgroup limit, not a second semaphore. The shared semaphore that bounds aggregate ARM calls is acquired only by the per-service goroutines inside each subscription client (
recommendations.gogoService) and released when they finish; the fan-out goroutines never hold it while waiting on the limit, so the two bounds cannot deadlock. The doc comment says so. Per-service slot holding is a separate concern (#8).Closes #58
Tests
TestMultiSubscriptionRecommendationsClient_GetRecommendations_BoundsConcurrency: 24 subscriptions with the limit set to 3, a fake client tracking peak in-flight calls, asserting1 < peak <= 3. Fails on origin/main ("24" is not less than or equal to "3"); removingSetLimitfails it the same way. Passes with-race -count=10.Verification
make build,make vet,(cd providers/azure && GOWORK=off go test -race -short .), pinned golangci-lint v2.10.1 (0 issues), gofmt, and the commit/pre-push hooks pass.Local review: non-author review of the diff, including where the shared semaphore is acquired and released, no findings.
🤖 Generated with Claude Code
Summary by CodeRabbit