Repository navigation
perf(azure database): batched per-server lookup for AZConfig (closes #149) - #812
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 4 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai review |
Rate Limit Exceeded
|
|
@coderabbitai full review Generated by Claude Code |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Get PR details and files changed
gh pr view 812 --repo LeanerCloud/CUDly --json title,body,files,additions,deletions,commits
echo "=== PR DIFF ==="
gh pr diff 812 --repo LeanerCloud/CUDlyLength of output: 24586
🔴 Medium — Misleading log message when a page walk partially succeedsFile: When a page fetch fails mid-walk, the warning says "signal unavailable", but the function returns the partial counts it collected up to that point. Example: page 1 returns 3 zone-redundant instances, page 2 errors → Choose one of two consistent paths: Option A — document partial-data use (optimistic): logging.Warnf("azure database: managed instances page fetch failed after %d instances: %v — AZConfig/Deployment derived from partial data", total, err)
return zoneRedundant, nonZoneRedundant, totalOption B — zero out on any error (conservative, matches the "unavailable" wording): logging.Warnf("azure database: managed instances page fetch failed: %v — AZConfig/Deployment signal unavailable", err)
return 0, 0, 0The same choice applies to the equivalent warning in 🟡 Low — Missing test for the mixed-deployment branch
func TestDatabaseClient_ConvertAzureSQLRecommendation_DeploymentAmbiguous(t *testing.T) {
client := NewClient(nil, "test-subscription", "eastus")
client.SetCapabilitiesClient(&MockCapabilitiesClient{})
zr := true
client.SetManagedInstancesPager(&MockSQLManagedInstancesPager{
pages: []armsql.ManagedInstancesClientListResponse{
{ManagedInstanceListResult: armsql.ManagedInstanceListResult{
Value: []*armsql.ManagedInstance{
{Properties: &armsql.ManagedInstanceProperties{ZoneRedundant: &zr}},
},
}},
},
})
// Also has regular servers → mixed → Deployment=""
client.SetServersPager(&MockSQLServersPager{
pages: []armsql.ServersClientListResponse{buildServerPage(1)},
})
rec := mocks.BuildLegacyReservationRecommendation(mocks.WithNormalizedSize("GeneralPurpose_Gen5_2"))
out := client.convertAzureSQLRecommendation(context.Background(), rec)
require.NotNil(t, out)
details, ok := out.Details.(common.DatabaseDetails)
require.True(t, ok)
assert.Empty(t, details.Deployment, "mixed managed+regular must leave Deployment empty")
}ℹ️ Informational —
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Replace the per-server individual AZConfig/Deployment lookup with a batched approach that calls the API once per server list page, reducing API call volume proportionally to the number of SQL servers. Adds MockSQLServersPager and MockSQLManagedInstancesPager test helpers with CallCount tracking. Resolves conflict by including main's TestReservationResourceTypeSQLDB_IsCanonical (H2b regression test for SQLDatabases filter canonical value) alongside the new batched-lookup tests.
|
Rebased onto origin/main, all CI checks passed, squash-merged. |
Summary
GetRecommendationscall viasync.Once.ManagedInstancesClient.NewListPager+ServersClient.NewListPager, both cached for the client lifetime.ManagedInstanceProperties.ZoneRedundant("zoneRedundant" / "none" / "" when ambiguous). Deployment derived from managed-instance vs. regular-server presence ("managed" / "single" / "").Test plan
_PopulatesAZConfig: all zone-redundant managed instances ->AZConfig="zoneRedundant"_AmbiguousAZConfig: mixed zone-redundancy ->AZConfig=""_AZConfigPagerErrorFallsBack: pager error ->AZConfig="", conversion still succeeds_PopulatesDeployment: only managed instances ->Deployment="managed"_DeploymentSingle: only regular servers, no managed instances ->Deployment="single"_DeploymentPagerErrorFallsBack: servers pager error ->Deployment="", conversion still succeeds_ServerInfo_FetchedOnce: 10 converter calls -> managed-instances pager walked exactly oncego build ./...clean