Skip to content

fix(chart): bind OPA sidecar API to a per-pod UDS to end the 8181 host-port bind race - #499

Merged
bpalermo merged 1 commit into
mainfrom
fix/opa-sidecar-uds-api-8181-race
Jul 11, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/opa-sidecar-uds-api-8181-race

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Problem

The OPA authz sidecar (proposal 027 preset) crashloops 2-3 times on every proxy roll (and at install) with:

listen tcp 127.0.0.1:8181: bind: address already in use

Root cause

  • The proxy DaemonSet is hostNetwork: true → 127.0.0.1:8181 is a host-wide port, not pod-local.
  • The rollout uses maxSurge=1, maxUnavailable=0 (intentional — the new Envoy hot-restarts from the old across the pod boundary), so during every roll the old and new proxy pod run simultaneously on the same node.
  • Both pods' OPA sidecars try to bind the same host 8181 → the new one can't until the old pod fully exits → deterministic 2-3 restart bind race.

8181 is OPA's diagnostic HTTP API, which nothing here consumes — Envoy reaches OPA only over the ext_authz gRPC UDS (authz.sock).

Fix

Bind OPA's API to a per-pod UDS in the (per-pod) authz-socket emptyDir:

- - "--addr=127.0.0.1:8181"
+ - "--addr=unix:///run/aether/authz/opa-api.sock"

No host port → no cross-pod collision. Surge / hot-restart is untouched, and the ext_authz gRPC path is already a UDS.

Alternatives rejected

  • maxSurge=0 — kills the collision but breaks the hitless hot-restart handoff (the surge is load-bearing).
  • Per-pod distinct TCP port — impossible with an identical DaemonSet template.
  • SO_REUSEADDR — OPA doesn't expose it, and it wouldn't help across two distinct processes anyway.

Scope

8181 appeared only in this one template. The edge OPA sidecar is a normal Deployment (not hostNetwork), so it has no host-port collision — no change needed.

Validation

  • helm lint clean; template renders the UDS addr.
  • Found in the 2026-07-10 8h churn soak (benign for the data plane thanks to maxUnavailable=0+surge keeping the old pod serving, but it stalls roll completion ~2-3 min). Post-merge: roll ds/aether-proxy on talos and confirm the authz sidecar comes up with 0 restarts.

Chart bumped 0.71.0 → 0.72.0.

🤖 Generated with Claude Code

…t-port bind race

The OPA authz sidecar (proposal 027 preset) ran its diagnostic API on
`--addr=127.0.0.1:8181`. But the proxy DaemonSet is `hostNetwork: true`, so
127.0.0.1:8181 is a HOST-wide port, and the rollout uses `maxSurge=1,
maxUnavailable=0` (intentional — the new Envoy hot-restarts from the old across
the pod boundary). During every proxy roll the old and surged-in new pod run
simultaneously on the same node and both OPA sidecars try to bind the same host
8181 → the new one crashloops with `listen tcp 127.0.0.1:8181: bind: address
already in use` until the old pod exits. Result: a deterministic 2-3 restart
warm-up on every proxy roll (and at install, which is also a roll).

Nothing consumes 8181 — Envoy reaches OPA only over the ext_authz gRPC UDS
(authz.sock). Move OPA's API onto a per-pod UDS in the (per-pod) authz-socket
emptyDir so there is no host port to collide on. Surge/hot-restart is unchanged.

Observed in the 2026-07-10 8h churn soak: benign for the data plane (maxUnavailable=0
+ surge keeps the old pod serving until the new one is Ready), but it stalls roll
completion ~2-3 min and is noise. This removes it.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S
@bpalermo
bpalermo merged commit 2b32b07 into main Jul 11, 2026
14 checks passed
@bpalermo
bpalermo deleted the fix/opa-sidecar-uds-api-8181-race branch July 11, 2026 10:54
bpalermo added a commit that referenced this pull request Aug 1, 2026
Renumber 002 -> 034 (002 is taken by the merged agent-concurrency
audit) and revise every code reference after two months of drift:

- Ports post-030: inbound is 18008 (defaultInboundPort); the outbound
  listener is unchanged at 18081 (mesh.ProxyOutboundPort)
- Multi-port routing (005): delivery is app_<pod>_<port>, so the
  original "port is ignored for delivery" semantic is REVERSED —
  port(s) stay required for demux/EDS; the annotation only changes
  what the app cluster dials (one socket serves all declared ports)
- Redirect-all (022) + mesh DNS narrowed Phase 2's audience; keep it,
  priority lowered, re-evaluate after Phase 1
- E/W waypoint (019) and cleartext inbound (#421) confirmed covered
  for free (delivery sits behind the inbound listener)
- New facts folded in: UID already fetched but deliberately not
  persisted (resubscribe.go), storage is protojson in agent/storage,
  builder is exported GenerateOutboundHTTPListener with the 025/#470
  extension union (hoisted per-loop in #615), authz emptyDir socket
  (#499) documented as the intra-pod precedent (cross-pod still needs
  the kubelet hostPath), RESULT_IGNORED unmanaged pods, TCP
  connect-probe analogue on pipes
- New constraint: the kubelet-pods mount must not be readOnly
  (connect(2) on AF_UNIX needs write on the inode; EROFS otherwise)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
bpalermo added a commit that referenced this pull request Aug 1, 2026
* docs: proposal 002 — UDS support for pods

Plan for letting pods serve on and dial the mesh via Unix domain sockets,
in two phases (inbound first). Pathname UDS is mount-namespace-scoped, so
the design bridges pod emptyDir volumes to the node proxy through kubelet's
pod-volumes directory; abstract sockets and workload hostPath mounts are
evaluated and rejected. Registry/EDS endpoints stay TCP :15008, so UDS pods
are indistinguishable from TCP pods to clients.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* docs(034): re-ground the pod-UDS proposal in the current codebase

Renumber 002 -> 034 (002 is taken by the merged agent-concurrency
audit) and revise every code reference after two months of drift:

- Ports post-030: inbound is 18008 (defaultInboundPort); the outbound
  listener is unchanged at 18081 (mesh.ProxyOutboundPort)
- Multi-port routing (005): delivery is app_<pod>_<port>, so the
  original "port is ignored for delivery" semantic is REVERSED —
  port(s) stay required for demux/EDS; the annotation only changes
  what the app cluster dials (one socket serves all declared ports)
- Redirect-all (022) + mesh DNS narrowed Phase 2's audience; keep it,
  priority lowered, re-evaluate after Phase 1
- E/W waypoint (019) and cleartext inbound (#421) confirmed covered
  for free (delivery sits behind the inbound listener)
- New facts folded in: UID already fetched but deliberately not
  persisted (resubscribe.go), storage is protojson in agent/storage,
  builder is exported GenerateOutboundHTTPListener with the 025/#470
  extension union (hoisted per-loop in #615), authz emptyDir socket
  (#499) documented as the intra-pod precedent (cross-pod still needs
  the kubelet hostPath), RESULT_IGNORED unmanaged pods, TCP
  connect-probe analogue on pipes
- New constraint: the kubelet-pods mount must not be readOnly
  (connect(2) on AF_UNIX needs write on the inode; EROFS otherwise)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant