Skip to content

feat: discover role assignment quota from Azure - #6494

Open
roi (roivaz) wants to merge 3 commits into
Azure:mainfrom
roivaz:dynamic-role-assignment-quota
Open

feat: discover role assignment quota from Azure#6494
roi (roivaz) wants to merge 3 commits into
Azure:mainfrom
roivaz:dynamic-role-assignment-quota

Conversation

@roivaz

@roivaz roi (roivaz) commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Tracking: https://redhat.atlassian.net/browse/AROSLSRE-1789

What

  • Query Microsoft.Authorization/roleAssignmentsUsageMetrics for each configured subscription.
  • Export both role-assignment usage and the subscription-specific limit returned by Azure.
  • Replace the paginated role-assignment listing with one authoritative API request.
  • Keep the existing roleAssignmentLimit deployment configuration temporarily for rollout compatibility.
  • Update subscription onboarding documentation because static limit configuration is no longer required by the new exporter.
  • Keep the existing Prometheus metric names and labels unchanged.

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 roleAssignmentLimit field; the old binary would default missing values to 4000, producing incorrect limits for subscriptions configured at 8000.

Follow-up config cleanup: #6505

Testing

  • go test ./... in tooling/tenant-quota
  • go build ./... in tooling/tenant-quota
  • targeted golangci-lint for tooling/tenant-quota/...
  • compatibility unit test proving the new config parser accepts the legacy roleAssignmentLimit field
  • audited docs/ for other static role-assignment-limit configuration references
  • make run with live DEV credentials; /healthz and /readyz returned OK and all 11 configured subscriptions exported RBAC usage and API-reported limits

PR Checklist

  • PR is scoped to a single task (no mixed concerns)
  • Title follows Conventional Commits format
  • Summary explains the "Why" behind the change
  • Linked to relevant ticket/issue
  • Screenshots included (if graph/UI/metrics changes) — metric schema and visualizations are unchanged
  • Self-reviewed the diff
  • CI/CD checks are passing (ignore Tide) — pending draft PR CI
  • Draft PR used for WIP (if applicable)
  • Commit history is clean (rebased/squashed)
  • Tricky code blocks are commented
  • Specific reviewers tagged — intentionally deferred until author review
  • All comment threads resolved before merge

@openshift-ci

openshift-ci Bot commented Aug 10, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

roi (roivaz) and others added 2 commits August 11, 2026 14:01
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>
@roivaz
roi (roivaz) force-pushed the dynamic-role-assignment-quota branch from f031d97 to 1236c70 Compare August 11, 2026 12:02
@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@roivaz
roi (roivaz) marked this pull request as ready for review August 11, 2026 14:28
Copilot AI lite review requested due to automatic review settings August 11, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 roleAssignmentLimit from 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.

Comment thread tooling/tenant-quota/pkg/subscriptionquota/roleassignmentmetrics.go
Comment thread tooling/tenant-quota/pkg/subscriptionquota/roleassignments_test.go
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>
Copilot AI review requested due to automatic review settings August 11, 2026 14:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants