Repository navigation
Preserve UniFi admission guards while migrating to ValidatingPolicy #5459
Description
🤖 Generated by the Agentic Engineer
Objective
Preserve the existing UniFi apply, observe-only and deletion boundaries while replacing their retiring ClusterPolicy API with ValidatingPolicy. This is one independently deployable slice of #4995, not a network-configuration change.
Evidence and scope
At Platform source a2b34a68d839754a411168de919985b9f3f21ea5, the existing four fixture families produce 19 passing expected outcomes on both Kyverno 1.19.1 and the current 1.19.2 CLI. The three legacy rules separately check ordinary apply, observe-only annotations and deletion of the stored object; other applying identities are excluded. Missing and empty management-policy lists have conservative existing defaults that must be retained.
Represent the three independently testable legacy rules as equivalent ValidatingPolicy resources where needed to preserve their individual expected results. Retain the existing API groups, resource coverage, admission operations, namespace/source-writer boundary, failure action and controller/operator exclusions. Do not expand supported resource kinds or alter the managed network objects.
Acceptance criteria
- Preserve the 19 original resource/outcome cases and old-policy baseline receipts. Add meaningful controls for UPDATE, default/empty/null values, wrong scope and unrelated identities before rewriting; prove the relevant assertions fail when each protection is broken.
- The replacement policies preserve CREATE/UPDATE incoming-object checks and DELETE stored-object checks, literal wildcard/Delete handling, exact observe-only behavior and the original denial behavior. Keep individual legacy-rule outcome parity explicit.
- Stage the migration without an enforcement gap: first deploy the replacement policies alongside the unchanged legacy guard and verify each replacement Ready against the published source; only then remove the legacy ClusterPolicy in a separate protected change. Temporary validation overlap must not change the admitted object. Keep each new policy's resource coverage aligned with the existing tenant Role, and retain an adverse control that rejects drift.
- Adapt the fixture-evaluation/failure-action and effective-policy consumers without dropping meaningful coverage. Full applicable policy tests, offline regressions and manifest-layer validation pass; do not suppress readiness/reporting failures or broaden permissions to hide them.
- Obtain current-head substantive review and complete required CI, then use the normal protected merge/deployment path. After deployment, read back every replacement as Ready and the old ClusterPolicy as absent, binding the evidence to the published source. Local tests and pre-existing stored objects alone are not production acceptance.
Boundaries and priority
Part of #4995. The separate additional-resource work in #4992 and the parent's other validation policies remain independent. No local cluster, ad-hoc writes to managed resources, provider/account/credential change, network mutation, paid service or unrelated release activation is required or authorized by this task.
Priority High; Effort Medium; Service class Risk reduction. The current guard already works; this preserves it across the planned API retirement rather than treating a future upgrade as a current incident.
Delivered on: 2026-10-28. Native acceptance: #5459 (comment)
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Start date
Effort
Projects
- StatusShow more project fields✅ Done
Activity
chore: agent-claim #5459 nonce=54eeffe93b95fd2d9c0ec58ed56bc6e5
devantler commentedon Oct 27, 2026
The expanded legacy characterization now passes 56 outcomes on both Kyverno 1.19.1 and 1.19.2, including UPDATE, empty/null defaults, future served versions, group/kind pairing, other namespaces and other identities. The full current suite passes 920 cases and the fixture-evaluation guard validates 99 files. Six deliberate single-rule breaks are rejected.
I refined the rollout criterion to two protected deployments. Flux prunes removed resources before checking replacement health; applying both kinds in one reconciliation alone therefore does not prove uninterrupted enforcement. First add and verify the replacements alongside the unchanged legacy policy; remove the legacy policy only after all replacements are Ready. Each replacement fixture loads only the new policy file so the old guard cannot mask a missing or ineffective replacement.
Source: Flux reconciliation order. No managed network objects or permissions change.
chore: agent-claim #5459 nonce=15a731126d331c6df9dda1041d25ffc0
devantler commentedon Oct 28, 2026
Completed the staged migration through #5462 and the separately protected retirement #5479, merged as
d4eff1085e6e18509dd7451ec424bfbc8c926c7b. The three replacement guards were observed Ready before the old guard was removed.The original 19 expected cases are preserved. The expanded baseline, split rule outcomes, adverse controls and scope tests passed on both supported Kyverno CLI versions. The retirement passed the complete policy suite, fixture/failure-action consumers, manifest-layer validation and applicable schema checks, followed by exact-head Codex review and full required CI. Access remains aligned with the existing supported tenant resources; no managed network object or controller activation changed.
Production acceptance is now observed:
restrict-unifi-management-policiesClusterPolicy is absent.8e19401e598c738dc31917edbc2dff9a12c84f29contains that merge and preserves the replacement and tenant-access files exactly. Its successful deployment published and observed artifactsha256:dda3e4390d0762bd5b1fba584b7316c211831360c2bf76769f94a9535f8ab629, with no failed prune. Independent live readback finds the same artifact signature-verified and applied, with the source and infrastructure Ready at their current generations.All acceptance criteria for this UniFi slice are met. The other validation and mutation families under #4995 and #4997 remain separate work.