← Back to Pull requests

refactor(backend): collapse deny assignments into a single complete deny assignment #6979

Closed
unknown closed this pull request without merging on Sep 29, 2026 11:21 UTC
View on GitHub
unknown unknown commented on Sep 16, 2026 13:00 UTC
Author

Summary

Collapses the backend's ~19 per-service deny assignments into a single consolidated complete-deny-assignment. This brings the ARO-HCP backend into parity with both Cluster Service and ARO Classic, which each enforce cluster deny policy through one consolidated deny assignment of this shape.

Cluster Service stopped creating deny assignments, so the backend is now the sole owner. Rather than inventing something new, the backend adopts the same complete assignment CS previously produced — same suffix → same deterministic UUID → same policy.

The single deny assignment

The controller writes exactly one Azure deny assignment, scoped to the cluster's managed resource group:

Name:              generateDenyAssignmentUUID(csClusterID, "complete-deny-assignment")   # deterministic v5 UUID
Scope:             /subscriptions/<sub>/resourceGroups/<managed-resource-group>
IsSystemProtected: true

Principals:
  - id:   00000000-0000-0000-0000-000000000000        # AllPrincipals
    type: SystemDefined

Permissions:
  Actions:
    - */action
    - */delete
    - */write
  NotActions:
    - Microsoft.Compute/disks/beginGetAccess/action
    - Microsoft.Compute/disks/endGetAccess/action
    - Microsoft.Compute/disks/write
    - Microsoft.Insights/ActionGroups/write
    - Microsoft.Insights/ActionGroups/delete
    - Microsoft.Insights/MetricAlerts/write
    - Microsoft.Insights/MetricAlerts/delete
    - Microsoft.Insights/ActivityLogAlerts/write
    - Microsoft.Insights/ActivityLogAlerts/delete
    - Microsoft.Compute/snapshots/beginGetAccess/action
    - Microsoft.Compute/snapshots/delete
    - Microsoft.Compute/snapshots/endGetAccess/action
    - Microsoft.Compute/snapshots/write
    - Microsoft.Network/networkInterfaces/effectiveRouteTable/action
    - Microsoft.Network/networkSecurityGroups/join/action
    - Microsoft.Resources/tags/*                        # tagging stays allowed
    - Microsoft.PolicyInsights/remediations/write
    - Microsoft.PolicyInsights/remediations/delete
    - Microsoft.Authorization/roleAssignments/write
    - Microsoft.Network/dnszones/CAA/write
    - Microsoft.Network/dnszones/CAA/delete
    - Microsoft.Network/dnszones/TXT/write
    - Microsoft.Network/dnszones/TXT/delete
    - Microsoft.Compute/virtualMachines/retrieveBootDiagnosticsData/action
  DataActions:    []
  NotDataActions: []

ExcludePrincipals: (resolved principal IDs of the cluster's managed identities)
  - control-plane operators: cluster-api-azure, cloud-controller-manager, control-plane,
    image-registry, ingress, cloud-network-config, disk-csi-driver, file-csi-driver
  - kms                     (only when customer-managed KMS etcd encryption is enabled)
  - data-plane operators:   image-registry, disk-csi-driver, file-csi-driver
  - the cluster's service managed identity  (always)

Effect: all principals are denied /write, /delete, /action on the managed resource group except the NotActions above; the excluded operator/service identities retain full access.

Parity with Cluster Service and ARO Classic

  • ARO Classic enforces its cluster resource-group deny policy through a single deny assignment of exactly this shape (AllPrincipals denied, operator identities excluded, IsSystemProtected). This change gives ARO-HCP the same consolidated model.

  • Cluster Service previously created this same complete-deny-assignment. The definition is byte-for-byte the same policy — same suffix/UUID, actions, notActions, excluded-principal set, and empty dataActions. Two intentional, behaviour-preserving deltas:

  • - KMS gating reads the coreapi field via isKMSEncryptionEnabled(cluster) (customer-managed key-management mode with a configured KMS), equivalent to CS's EncryptionType == AzureDataEncryptionKms check.
    - The backend always writes this single assignment, whereas CS attempted it and fell back to a split set of per-service assignments when it hit Azure's historical "&lt;10 excluded principals" limit.

    Suffix / UUID

    complete-deny-assignment is deliberately the same suffix Cluster Service used, so the deterministic UUID produced by generateDenyAssignmentUUID is unchanged. Pinned by TestGenerateDenyAssignmentUUIDMatchesClusterService; generateDenyAssignmentUUID is not touched.

    What happens when this merges

    Each cluster is reconciled by the deny-assignment controller with an ensure-before-delete ordering so there is no protection gap:

    1. The required set becomes exactly { complete-deny-assignment }.
    2. The controller ensures the complete assignment first — creating or updating it in Azure.
    3. Only once the complete assignment is confirmed present does it delete the now-obsolete legacy per-service assignments (resources, compute, resourcehealth, apimanagement, storage, managedidentity, keyvault, containerservice, deny-all-other-rps, and all network-
    ), removing them from Azure and from both the AzureResources and PendingAzureResources status lists.
    4. If the complete ensure fails, the legacy assignments are left in place and cleanup retries on the next reconcile — the managed resource group is never left without a deny assignment.

    Timing: the transition is eventually-consistent, not necessarily on the very next sync. A cluster that has already completed a reconcile is re-reconciled when its recheck timer fires (recheckDuration/2 + jitter, roughly 6–18h). While it waits, the cluster keeps its existing legacy per-service assignments, which enforce the same effective deny policy — so the delay is cosmetic (fewer assignment objects), never a window without protection. Net: existing clusters transition from ~19 deny assignments down to 1 automatically, with no manual migration and no unprotected window. Deny assignments are also scoped to the managed resource group, so on cluster teardown Azure removes them in cascade with the resource group.

    Testing

  • go build ./backend/...

  • go test ./backend/pkg/controllers/cluster/denyassignments/... (incl. TestGenerateDenyAssignmentUUIDMatchesClusterService, plus new controller tests covering the ensure-before-delete gap and the PendingAzureResources pruning)
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: machi1990 Review duration: 18620m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6979"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository