feat: discover role assignment quota from Azure - #6494
Conversation
|
Skipping CI for Draft Pull Request. |
Use the ARM role assignment usage metrics endpoint for both current usage and the subscription-specific limit. Keep accepting the legacy configuration field so the new image can roll out before configuration cleanup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document that the tenant quota exporter discovers the subscription limit from Azure, so onboarding only needs the subscription name and regions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f031d97 to
1236c70
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: roivaz The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR updates the tooling/tenant-quota exporter to query role assignment usage + limit directly from Azure’s Microsoft.Authorization/roleAssignmentsUsageMetrics endpoint per subscription, removing reliance on a statically configured per-subscription limit while preserving rollout compatibility.
Changes:
- Replaces paginated role assignment listing with a single ARM request that returns both current usage and the subscription-specific limit.
- Removes
roleAssignmentLimitfrom the Go runtime config model while keeping legacy YAML compatibility (unknown field ignored) and updates unit tests accordingly. - Updates onboarding and tenant-quota documentation to reflect that role assignment limits are now discovered from Azure.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tooling/tenant-quota/README.md | Documents that RBAC usage/limits are retrieved from Azure rather than configured. |
| tooling/tenant-quota/pkg/subscriptionquota/roleassignments.go | Switches RBAC quota collection to a metrics-based client instead of listing role assignments. |
| tooling/tenant-quota/pkg/subscriptionquota/roleassignments_test.go | Reworks tests around injected metrics client and error paths. |
| tooling/tenant-quota/pkg/subscriptionquota/roleassignmentmetrics.go | Adds a minimal ARM client to call roleAssignmentsUsageMetrics and validate response shape. |
| tooling/tenant-quota/pkg/subscriptionquota/roleassignmentmetrics_test.go | Adds transport-level unit tests for request construction and error handling. |
| tooling/tenant-quota/pkg/subscriptionquota/collector.go | Updates default sources to use the new RBAC source constructor. |
| tooling/tenant-quota/pkg/config/config.go | Removes static role-assignment limit config fields/constants. |
| tooling/tenant-quota/pkg/config/config_test.go | Adds coverage proving legacy roleAssignmentLimit YAML is ignored. |
| tooling/tenant-quota/go.mod | Drops unused armauthorization SDK dependency. |
| tooling/tenant-quota/go.sum | Removes corresponding armauthorization checksums. |
| docs/ci/e2e-subscription-onboarding.md | Updates onboarding steps to remove the static roleAssignmentLimit requirement. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Close ARM response bodies on every HTTP response and correct error formatting in the associated tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tracking: https://redhat.atlassian.net/browse/AROSLSRE-1789
What
Microsoft.Authorization/roleAssignmentsUsageMetricsfor each configured subscription.roleAssignmentLimitdeployment configuration temporarily for rollout compatibility.Why
Role-assignment limits can differ between subscriptions and change after quota increases. Azure already exposes the authoritative current count and limit, so the exporter should not depend on a static value.
This code PR must land and its image digest must be rolled out before the follow-up config cleanup PR. The new binary safely ignores the legacy
roleAssignmentLimitfield; the old binary would default missing values to4000, producing incorrect limits for subscriptions configured at8000.Follow-up config cleanup: #6505
Testing
go test ./...intooling/tenant-quotago build ./...intooling/tenant-quotagolangci-lintfortooling/tenant-quota/...roleAssignmentLimitfielddocs/for other static role-assignment-limit configuration referencesmake runwith live DEV credentials;/healthzand/readyzreturnedOKand all 11 configured subscriptions exported RBAC usage and API-reported limitsPR Checklist