refactor(backend): collapse deny assignments into a single complete deny assignment #6979
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
machi1990
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:
Effect: all principals are denied
/write,/delete,/actionon the managed resource group except theNotActionsabove; the excluded operator/service identities retain full access.Parity with Cluster Service and ARO Classic
IsSystemProtected). This change gives ARO-HCP the same consolidated model.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'sEncryptionType == AzureDataEncryptionKmscheck.- 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 "<10 excluded principals" limit.
Suffix / UUID
complete-deny-assignmentis deliberately the same suffix Cluster Service used, so the deterministic UUID produced bygenerateDenyAssignmentUUIDis unchanged. Pinned byTestGenerateDenyAssignmentUUIDMatchesClusterService;generateDenyAssignmentUUIDis 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 theAzureResourcesandPendingAzureResourcesstatus 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 thePendingAzureResourcespruning)