Repository navigation
Conversation
Deployments without the admission webhook let out-of-allow-list WorkerResourceTemplate specs onto the cluster, where the controller would happily apply them. Replay the webhook's pure spec validation (the same allowed-kinds + structural checks ValidateCreate runs) in the WRT render path, so a rejected spec fails before any object is applied and surfaces as an applyError exactly like a render failure. - Export ValidateWorkerResourceTemplateSpecForApply and a shared AllowedKindsFromEnv helper in api/v1alpha1; the webhook and the reconciler now parse ALLOWED_KINDS through one code path. - RenderWorkerResourceTemplate takes the allow list and validates the spec first; an empty list denies all kinds, mirroring the webhook's fail-closed semantics. - Plumb the list through planner.Config, getWorkerResourceApplies, WorkerDeploymentReconciler, and cmd/main.go. - envtest sets ALLOWED_KINDS in setupTestEnvironment and covers the rejection with a new wrt-rejected-kind case.
…w-list enforcement The wrt-apply-failure envtest case regressed into testing the new validation path: FakeResource was not in the test ALLOWED_KINDS set, so the WRT was rejected at reconcile time and the real SSA apply-failure branch in execplan.go lost its only test. Add FakeResource to the test allow list and restore the original case comment; the validation path stays covered by wrt-rejected-kind (Deployment). Also: gofmt reconciler_events_test.go; move testAllowedKinds above createTestWRT's doc comment and reuse createTestWRT in the AllowedKindsRejection planner test; and note in docs/worker-resource-templates.md and the Helm manager.yaml comment that the controller enforces the allowed-kinds list at reconcile time, not only the webhook.
eniko-dif
force-pushed
the
eniko.dif/lift-wrt-freeze-path-b-no-webhooks-693232c4
branch
from
November 27, 2026 10:16
494e62b to
d340465
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When the validating admission webhook is not served (e.g. deployments that embed the controller via the public
controller.Newand don't run webhooks),WorkerResourceTemplatespecs are server-side-applied with controller identity and no validation of their own. The allowed-kinds allow-list was admission-time only. This closes that gap by enforcing the allow-list at reconcile time.What
validateWorkerResourceTemplateSpec) in the WRT apply path:RenderWorkerResourceTemplaterunsValidateWorkerResourceTemplateSpecForApplybefore rendering, so an out-of-allow-list spec is rejected before any object is applied, surfaced the same way other render/apply errors surface (RenderError→ApplyError).ALLOWED_KINDSunset) rejects every kind, matching the webhook's deny-all default.ConfigFromEnv()now populatesAllowedKindsfromALLOWED_KINDS, so programs embedding the controller viacontroller.NewwithoutWithAllowedKindsinherit the environment default;WithAllowedKindsremains the explicit override.HPAMatchLabelsStripTemporalPrefixis not replayed (validation runs as if false); harmless because auto-injection overwrites those keys at render time — noted in theValidateWorkerResourceTemplateSpecForApplydoc comment.Tests
TestRenderWorkerResourceTemplate_RejectsKindOutsideAllowList,TestGetWorkerResourceApplies_AllowedKindsRejection, and the newTestConfigFromEnvAllowedKinds(table-driven,t.Setenv) cover the replay, the planner rejection path, and the env default. Verified they fail when the replay check or theConfigFromEnvdefault is removed.ALLOWED_KINDSso thewrt-apply-failurecase still reaches a real SSA failure.