Repository navigation
Conversation
…n it is applied, and its restart cases are in CI (#1447, #1448) A running OPA sidecar that is handed a policy it cannot compile keeps the last good one, and says so only in a log line at level info: no metric, no health endpoint, no status (measured on 1.21.1, status plugin on as well). No sidecar can start with that file, so the node's next sidecar restart fails every check per failureMode and its next pod replacement leaves the node without a proxy. Chart 2.4.23: with the OPA preset on, a one-pod Deployment, <release>-opa-policy-check, runs the sidecar's image with the same ConfigMap and `opa check` on the mounted file as its readiness probe (proxy.authzSidecar.opa.policyCheck, default on). Its pod template carries a checksum of the policy and it uses Recreate, so each policy change is judged by a new pod within seconds: the Deployment is unavailable, the pod's Unhealthy event carries the compile error, and `helm upgrade --wait` fails. It validates nothing before the update and takes no part in any request. The proxy DaemonSet renders byte-identical. It is a pod of its own because the same probe on the sidecar is unsafe: during a roll the DaemonSet controller deletes a NotReady old pod as soon as its replacement exists. Measured on kind with that probe: a bad policy, then a proxy roll, and the serving pod was deleted in the second it turned NotReady while its successor crash-looped. A guard test keeps the preset from rendering a readiness or liveness probe on the sidecar, and the values and docs for proxy.authzSidecar.readinessProbe say so. e2e/authz-bad-policy.sh (nightly job authz-bad-policy, its own kind cluster, e2e/authz.sh sourced): a deny-all policy is a decision; a policy that does not parse leaves the running sidecar deciding and is reported by the check; a stopped sidecar crash-loops while the proxy runs on and every check fails closed; a roll stalls with the old pod serving; a deleted pod leaves the node with no proxy after the successor wait (today's behaviour, pinned until the #1447 decision); a valid policy recovers it. Whether the proxy should start when its sidecar cannot is left to the owner; nothing here changes fail-open or fail-closed behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is isolated, thoroughly tested, and no unresolved correctness issues were identified.
0 open findings
What changed in this PR
Adds an isolated OPA policy compiler check and CI coverage for bad-policy restart scenarios.
Changes:
- Adds the configurable OPA policy-check Deployment.
- Adds destructive nightly authorization E2E coverage.
- Documents detection, impact, and recovery procedures.
| File | Description |
|---|---|
.github/workflows/e2e.yaml |
Adds the nightly bad-policy job. |
charts/aether/BUILD.bazel |
Adds Helm rendering tests. |
charts/aether/Chart.yaml |
Bumps chart version. |
charts/aether/templates/_helpers.tpl |
Adds policy-check naming and labels. |
charts/aether/templates/agent-proxy-opa-policy-check.yaml |
Defines the isolated checker Deployment. |
charts/aether/values.yaml |
Adds policy-check defaults and guidance. |
docs/configuration.md |
Documents new values and probe behavior. |
docs/runbook.md |
Documents detection and recovery operations. |
e2e/authz-bad-policy.sh |
Tests bad-policy lifecycle scenarios. |
e2e/authz.sh |
Supports reuse as a sourced harness. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Oct 9, 2026
Closed
Owner
Author
|
Closed on the owner's decision: the chart will not run a workload that checks policies. A policy is assumed to be tested before it is distributed (the standing rule from #1383), so what an untested policy does at a later restart is not something the chart or CI will cover. 🤖 Generated with Claude Code |
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.
Closes #1447
Closes #1448
An agent wrote this pull request.
The standing decision from #1383 bounds it: OPA runs with
--watch, and validating a policy is the job of whoever updates it, before the update. Nothing here validates, refuses or rolls back a policy. This is about seeing a policy that does not compile when it is applied, and about pinning in CI what it does at the restarts that follow.What changes
A policy check (chart
aether2.4.23,proxy.authzSidecar.opa.policyCheck, on by default with the OPA preset). One more pod, the Deployment<release>-opa-policy-check: the sidecar's image, the same ConfigMap mounted, and a readiness probe that runs/opa check /policy/policy.rego. Its pod template carries a checksum of the policy and its strategy isRecreate, so each policy change is judged by a new pod that mounts the ConfigMap as it is. With a policy that does not compile:kubectl rollout status deploy/aether-opa-policy-checkdoes not complete and the Deployment shows0/1;Unhealthyevent carries the compile error with file and line (measured 7 s afterhelm upgradebegan);kube_deployment_status_replicas_unavailable{deployment="aether-opa-policy-check"} > 0(standard kube-state-metrics, no log pipeline needed);helm upgrade --waitfails at its timeout. The ConfigMap is updated all the same: this reports, it does not block.It takes no part in any request and no proxy pod is touched.
e2e/authz-bad-policy.shand the nightly jobauthz-bad-policy(e2e: the bad-policy restart cases of the OPA sidecar are not in CI #1448): its own kind cluster,e2e/authz.shsourced for the bring-up (so it adds no image reference of its own). Steps under "Measured" below.Docs:
docs/runbook.md, new section A policy that does not compile (what to run before updating the ConfigMap, what OPA reports by itself, the signal and its query, what a bad file does at each later event, recovering a node whose proxy is down, the open decision);docs/configuration.mdrows; thereadinessProbe/livenessProbenotes for the sidecar now say what a failing readiness probe does to a roll.What an operator sees on upgrade. With the OPA preset on: one new Deployment (5m / 32Mi requests, 96Mi memory limit, no CPU limit,
GOMAXPROCS=1); the proxy DaemonSet renders byte-identical, so no proxy pod is replaced. With the preset off (the default), a bring-your-own sidecar, orpolicyCheck.enabled=false: the whole render is byte-identical tomain. Nothing to do; after the upgradekubectl -n aether-system rollout status deploy/aether-opa-policy-checkshould return 0.Why a pod of its own: the readiness probe was tried first, and it is unsafe
The smallest change would be
opa checkas theauthzsidecar's own readiness probe: the proxy pod turns NotReady on the node whose file is bad. I built that first and ran the new e2e against it. It reported the bad policy as designed, and then step e failed:maxUnavailable: 0protects only Ready pods: the DaemonSet controller deletes a NotReady old pod as soon as its replacement exists, whether or not the replacement becomes Ready. Without the probe the same roll stalls with the old pod serving (step e below, onmainand on this branch). So a readiness signal on the proxy pod turns "bad policy, then a roll" from a stalled roll into every node losing its proxy after the successor wait. The check therefore lives in a pod nothing depends on, a guard test keeps the preset from rendering a readiness or liveness probe on the sidecar, and the docs forproxy.authzSidecar.readinessProbe(which said it "gates a proxy roll") now say what it does.Measured
kind v0.33.0, Kubernetes 1.35.8, one node, OPA
1.21.1-envoy-static(sha256:b4a8bbe8…344b, verified withdocker buildx imagetools inspect),failureMode: DENYunless stated. Policies are changed withhelm upgrade, all values passed each time.What OPA itself exposes when a watched file fails to load (docker, the chart's exact arguments, a ConfigMap-style volume swapped the way the kubelet does; also with
status.console=trueandstatus.prometheus=true):/v1/policiesunchanged)/health,/health?plugins,/health?bundles{}, unchanged/metricsplugin_status_gauge{…status="OK"} 1for every plugin/v1/status"msg":"Processed file watch event."with a non-null"err", levelinfoSo the honest answer to "is there an OPA signal the chart can surface" is: a log line only.
opa checkagainst a startingopa run, per policy (the two agreed on all seven):opa checkopa runat start--watchsidecarload errorinitialization errorempty module)ext_authz.denied+2,error+0)envoy.authz.allowext_authzerror ("error":"undefined decision"), 403 under DENYCost of one
opa check: 30 ms wall, 33 MB peak RSS; inside a 128Mi container already running OPA the cgroup peak went from 14.9 MB to 23.6 MB over 40 runs.On kind, with the chart's real pod spec (each row is a step of
e2e/authz-bad-policy.shunless marked "by hand"):main(chart 2.4.21)ext_authz.error+0. Nothing reports it: no object and no event in the namespacenumberUnavailable0. Reported 7 s after the upgrade began:UnhealthyeventReadiness probe failed: … /policy/policy.rego:7: rego_parse_error: unexpected eof token, Deployment unavailable,rollout statusdoes not complete. (The file reached the node 75 s after the upgrade began.)authzcontainer stopped, bad file on the nodeInit:CrashLoopBackOff;proxy0 restarts, same epoch; allowed request 403,ext_authz.error0 → 2. Valid policy: 200 again in the same podfailureMode: ALLOW(by hand)failure_mode_allowed0 → 4 (it was 403 before the sidecar stopped)rollout restart ds/aether-proxy, bad file on the nodeproxynever starts; the roll stalls; old pod still decides 200 / 403,ext_authz.error+0000): the node has no proxyhelm upgrade --wait --timeout 60swith the bad policy (by hand)Error: UPGRADE FAILED: context deadline exceededafter 63 s, releasefailed, ConfigMap updated; the next upgrade with a valid policy returns it todeployedThe decision left open: should the proxy start when its sidecar cannot?
Not changed here. Row f is the remaining blast radius, and removing it means changing what #1275 guarantees.
proxyonly after the sidecar's startup probe passes. With a bad file on the node a new pod never starts its proxy. A surge roll stalls safely (row e). Any replacement without a surviving old pod (pod deleted, node drained, rebooted or added) leaves the node with no data plane: every route, including routes with noextAuthz, and regardless offailureMode. It never serves a request unchecked and never answers a spurious 403; it serves nothing.failureModedecides. Routes withextAuthzget 403 under DENY and pass unchecked under ALLOW; every other route works. That is what already happens when only the sidecar restarts (rows d and d'), so B makes a pod replacement behave like a sidecar restart. Its costs: under ALLOW a node comes up servingextAuthzroutes unchecked until someone notices (ext_authz.failure_mode_allowed), and proxy pod: the ext_authz sidecar can start after the proxy is serving — authz errors (403 under failureMode DENY) until it is up #1275's invariant becomes "the proxy waits for its authz up to N seconds" instead of "always". It needs a startup probe that can give up (a flag onproxy-ready, staged one release before the chart uses it), not a values change.bundles.<n>.resource=file:///policy/..dataandpersist=trueit logsPersisting bundle to disk failed: no raw bundle bytes to persist to diskand never activates (docker, 1.21.1). It would mean shipping the policy as a tarball and dropping--watch, which chart: the OPA authz sidecar does not watch its policy, so a policy change needs a proxy roll #1383 decided against.Recommendation: B. With the default
failureMode: DENYnothing is ever served unchecked under B, and the outage shrinks from "the node" to "routes that asked for authorization on that node". Under ALLOW the operator has already chosen availability over enforcement for exactly this failure, and today that choice is honoured for a sidecar restart and overridden by a node outage for a pod replacement. It is the owner's call because it trades a guarantee for availability; the e2e's step f pins today's behaviour and says in its failure message that it must change with that decision.Render, before and after
helm templateofmainand of this branch, same version string on both sides,--kube-version 1.35.0:policyCheck.enabled=falsemain's OPA preset renderThe added document, comments omitted:
Decisions in it:
GOMAXPROCS=1, no CPU limit. The container's OPA is idle and the probe is a new 30 ms Go process every period; without the pin both would size themselves to the node's cores.proxy.authzSidecar.opa.image, the sidecar's value, so the check always runs the OPA the sidecars run, and it follows the digest pin of fix(chart, e2e): third-party images are pinned by digest from one inventory with a check; every udsecho object is labelled (#1400, #1401, #1402) #1476 when that lands (this branch adds no image reference).opa run --serverwith no policy argument: the image holds one binary and a pod needs a process. Given the policy it would exit on a bad one, and the signal would be a crash loop without the error in an event.failureModesemantics.Tests
Template tests, written first and run against the chart without the new template:
With the template: all green, and
bazel test //charts/... //bazel/helm/... //e2e/...passes. Thestrategy: Recreatepattern was added toaether_opa_policy_check_testtogether with the strategy, after the first kind run; it was not seen red on its own.e2e, on kind:
main's chart withABP_EXPECT=red(the gate of step c inverted: nothing may report the policy): passed, which is the evidence thatmainshows nothing;Recreatestrategy; the event came 7 s after the upgrade began both times);main's chart expecting the fix: fails in step a,the policy check is not available … deployments.apps "aether-opa-policy-check" not found;Locally: the lint build scoped to
//e2e/... //charts/... //bazel/helm/...with--config=lint --@aspect_rules_lint//lint:fail_on_violation,make format-check,make actionlint,scripts/check-shell-lint.sh.Not verified
scheduleandworkflow_dispatchonly). The script ran locally the way the job runs it (up,verify, withAUTHZ_SKIP_BUILD=1);only=authz-bad-policyon a dispatch is the first real run. It takes about 20 minutes after bring-up; the job's timeout is 60.helm upgrade --atomicwith a bad policy (expected to roll the release back at the timeout).helm --wait's behaviour.kube_deployment_status_replicas_unavailablewas checked to exist on a test cluster's kube-state-metrics; the alert expression itself was not evaluated against a failing check./v1/policiesagainst the hash of the mounted file. That is Go in the supervisor and a separate change.mainis at 2.4.21 and fix(chart, e2e): third-party images are pinned by digest from one inventory with a check; every udsecho object is labelled (#1400, #1401, #1402) #1476 takes 2.4.22, so this takes 2.4.23. If this merges first, fix(chart, e2e): third-party images are pinned by digest from one inventory with a check; every udsecho object is labelled (#1400, #1401, #1402) #1476 needs the next number, and the reverse.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr