Repository navigation
feat(agent): log outbound identity bindings on change and flag foreign-identity binds (#638) - #686
Merged
Merged
Conversation
…n-identity binds (#638) The #638 discriminator: make the source-side (source pod -> outbound cluster -> SDS client-cert secret) binding observable, so the next soak can confirm or kill the "a fresh proxy briefly presents a co-located pod's SVID" hypothesis. Reading the generator settles part of the question up front. Every mTLS-injected outbound cluster carries the SAME two things (proxy.InjectUpstreamMTLS): one transport_socket_match per unique local SPIFFE ID, NAMED by that SPIFFE ID and fetching the SDS secret of the same name, and a matcher from the source pod's netns to one of those names built from c.localWorkloads. Socket name and secret name are literally the same string, so "this match presents a secret it is not named for" is structurally impossible, and the binding is node-wide identical across clusters -- exactly the shape the field data shows. What CAN go wrong is the netns -> SPIFFE ID index itself: localWorkloads (localMu) and listeners (listenerMu) are written non-atomically on the add path, the remove path and the storage merge, and the key is a netns PATH the CNI reuses. So the log line goes at that seam, cross-checked against the pod that actually owns the netns (proxy.SpiffeIDFromPod over the listener's own CNIPod). - INFO "outbound identity binding" per (source pod, cluster), emitted only on a change or first sight, so steady state is silent; above 200 changed pairs in one snapshot a single summary keeps the distinct source->identity transitions. - WARN "outbound cluster bound to a foreign identity" + the new counter aether.agent.identity.outbound_binding_mismatch when the bound secret is not the owning pod's own SPIFFE ID; WARN "outbound identity mapping has no owning pod" for an orphaned mapping (missed CNI DEL). - Runbook section with the grep/LogsQL/PromQL recipe for a soak window. Refs #638 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…ing-discriminator
bpalermo
added a commit
that referenced
this pull request
Sep 5, 2026
… zero) (#693) The § 8 recipe selected `_stream:{k8s_container_name="agent"}`, which matches no stream on this cluster: the stream labels are the dotted OTel resource fields (service.name, k8s.pod.name, k8s.namespace.name). As written, the foreign-identity alarm query returned zero rows on a run where the lines existed. Found by the rev193 validation of #686. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
This was referenced Sep 5, 2026
TRIPLE-window liveness anomaly: 2-for-2 across consecutive soaks, different mechanism each time
#629
Closed
bpalermo
added a commit
that referenced
this pull request
Sep 5, 2026
) Envoy's SAN-matcher failure prints the SANs of the certificate being VALIDATED — the PEER's — so ssl_fail_verify_san is a CLIENT-side counter about the SERVER's certificate. Inverted, the wrong identity in a #638 event belongs to a server cert: the inbound filter chain → SDS server-secret binding of the proxy that TERMINATED the connection. #686's outbound check watches the client side and cannot fire for it. On every snapshot the agent now reads each local pod's inbound listener back out of the snapshot it just handed Envoy, extracts each chain's DownstreamTlsContext server-cert secret name, and compares it with the SPIFFE ID of the pod that listener entry belongs to: - INFO "inbound identity binding" on a first bind or a change - WARN "inbound chain bound to a foreign identity" + the counter aether.agent.identity.inbound_binding_mismatch - WARN "inbound chain references a secret absent from the snapshot" (the chain reached Envoy before its own SVID) - a summary line above 200 changed chains in one snapshot The binding holds by construction inside proxy.NewInboundListener, which is the point: a counter that stays 0 through a #638 event, with INFO lines showing correct re-binds, moves the defect out of the agent's snapshot and into Envoy's SDS/secret lifecycle across the hot restart. Fail-open: observes after SetSnapshot, never blocks or alters it. docs/runbook.md gains the attribution recipe for the ledger join — upstream_host → pod → node vs. the node whose proxy was restarting, with the documented false-zero traps (LogsQL field syntax, max_over_time). Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Sep 5, 2026
… absence is not a false zero (#638) (#717) The OTel SDK exports a counter only after its first Add. Both discriminator counters (outbound #686, inbound #715) are never incremented in the healthy case, so neither series existed in Prometheus on talos-main rev200 and a grading increase() would return no data, indistinguishable from zero. Seed both at process start; test pins it. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
This was referenced Sep 19, 2026
bpalermo
added a commit
that referenced
this pull request
Sep 19, 2026
…on on inbound mTLS readiness (#815) Release ONE of the two-release fix for #815. Listeners change; clusters do not. Part A — every chain that can originate mesh traffic now sets a SECOND filter-state object, `aether.source.spiffe_id`, carrying the source pod's SPIFFE ID as a literal, alongside the existing `aether.network.network_namespace` key. Same `shared_with_upstream: ONCE` semantics, because it is destined for the same consumer: the cluster transport-socket matcher reads both through `TransportSocketOptions::downstreamSharedFilterStateObjects()`. The matcher is NOT changed — clusters stay byte-identical, asserted by TestClusterMatcherStillKeyedOnNetns and the per-pod half of TestLocalPodChurnRewritesEveryServiceCluster. Release two flips the matcher's FilterStateInput to the new key, which makes the Cluster proto byte-stable across pod churn and ends the 15s node-wide EDS re-warm + pool drain that one CNI ADD currently costs. Doing both in one step would leave a cluster with the new input facing a listener with only the old key falling to OnNoMatch = the node identity = the wrong client certificate (#686). The old key can only be removed in a THIRD release, for the mirror-image reason. Contract documented at the constant. Chains stamping both keys: per-pod outbound HTTP, capture HCM, capture TCP floor, capture TCPRoute weighted floor, capture TLSRoute SNI. The ORIGINAL_DST passthrough chain stamps neither (plaintext, selects no certificate) and the UDP capture listener has no filter chains at all. Part B — a second per-pod probe cluster, `inboundready_<pod>`, closes the promotion hole. `health_<pod>` dials the application in cleartext and has no SDS dependency, while the pod's inbound listener does not listen() until its SVID arrives, so an endpoint could be advertised HEALTHY while its mesh port refused connections (promotion p50 5.8s vs SVID 6.1-8.4s; one pod promoted in <=0.5s). The new cluster runs a connect-only TCP health check over an mTLS UpstreamTlsContext against the pod's own 127.0.0.1:18008 in its netns, ALPN h2 / no SNI so it lands on the always-present no-SNI inbound chain, client cert = the node SVID, peer pinned to exactly the pod's SPIFFE ID. Envoy raises Connected only after the TLS handshake, so a pass means "listening, has this pod's certificate, and it verifies as this pod". Inbound validation is untouched: it already requires a client certificate and validates the trust-domain bundle with no SAN restriction, so the node identity is accepted as-is. The gateway filter for the pod requires both clusters; the gateway PATH is unchanged, so the liveness loop and health client are untouched. The probe is not emitted with SPIRE off (cleartext inbound: nothing to prove) or before the node SVID lands (no client certificate) — those pods keep exactly the previous single-cluster gate, so SPIRE-off snapshots are unchanged. The main risk is the other direction: a new Envoy epoch starts every host failed and must re-fetch each pod's SDS secret, so a proxy roll would otherwise demote every pod on the node. The existing warm-up grace does not cover it (it only applies to pods that never served). Two guards: a previously-serving pod is demoted only after 3 consecutive failing observations (15s), and any tick that could not reach the gateway re-arms the full warm-up grace on the next tick that can. Cost: a genuinely dead app is demoted ~10s later; fast local detection is outlier detection, which is unaffected. Per-pod probe clusters use a plain UpstreamTlsContext, never the per-source matcher, so adding one does not perturb any other cluster's bytes. Also: extend the chart's stats exclusions to the new prefix while keeping membership_* (the health_check filter READS those gauges) and ssl.* (the direct read-out of why a pod is stuck un-promoted) readable; runbook section on what HEALTHY now means and how to read a stuck pod; amendment on proposal 004. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 19, 2026
…ires an mTLS handshake with the pod's inbound listener (#815, release 1/3) (#819) * test(xds/cache): pin the delta-xDS no-op push, characterise pod-churn CDS blast radius Two tests, no production change, written while investigating the suspected "inbound listener published before its SDS secret" ordering defect. TestSnapshotRegenerationIsANoOpPush pins the steady-state half of the #135 invariant that determinism_test.go only covers across independent builds: regenerating with unchanged inputs must be byte-identical, because the agent pushes a full snapshot per event (~9/node/minute measured during a soak scale-up) and every one of those is free only while unchanged config hashes unchanged. TestLocalPodChurnRewritesEveryServiceCluster records what one pod's lifecycle actually costs the node's CDS set. Every mesh service cluster carries a per-source upstream-mTLS matcher whose exact_match_map is keyed by the source pod's netns path, so one pod arriving or leaving rewrites EVERY service cluster the node holds - measured here as 9 of 9, independent of any routing relationship to that pod. The DEL restores the pre-ADD bytes exactly, so create/destroy is a round trip rather than a ratchet; both halves are asserted. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * feat(agent): stamp the source SPIFFE ID in filter state, gate promotion on inbound mTLS readiness (#815) Release ONE of the two-release fix for #815. Listeners change; clusters do not. Part A — every chain that can originate mesh traffic now sets a SECOND filter-state object, `aether.source.spiffe_id`, carrying the source pod's SPIFFE ID as a literal, alongside the existing `aether.network.network_namespace` key. Same `shared_with_upstream: ONCE` semantics, because it is destined for the same consumer: the cluster transport-socket matcher reads both through `TransportSocketOptions::downstreamSharedFilterStateObjects()`. The matcher is NOT changed — clusters stay byte-identical, asserted by TestClusterMatcherStillKeyedOnNetns and the per-pod half of TestLocalPodChurnRewritesEveryServiceCluster. Release two flips the matcher's FilterStateInput to the new key, which makes the Cluster proto byte-stable across pod churn and ends the 15s node-wide EDS re-warm + pool drain that one CNI ADD currently costs. Doing both in one step would leave a cluster with the new input facing a listener with only the old key falling to OnNoMatch = the node identity = the wrong client certificate (#686). The old key can only be removed in a THIRD release, for the mirror-image reason. Contract documented at the constant. Chains stamping both keys: per-pod outbound HTTP, capture HCM, capture TCP floor, capture TCPRoute weighted floor, capture TLSRoute SNI. The ORIGINAL_DST passthrough chain stamps neither (plaintext, selects no certificate) and the UDP capture listener has no filter chains at all. Part B — a second per-pod probe cluster, `inboundready_<pod>`, closes the promotion hole. `health_<pod>` dials the application in cleartext and has no SDS dependency, while the pod's inbound listener does not listen() until its SVID arrives, so an endpoint could be advertised HEALTHY while its mesh port refused connections (promotion p50 5.8s vs SVID 6.1-8.4s; one pod promoted in <=0.5s). The new cluster runs a connect-only TCP health check over an mTLS UpstreamTlsContext against the pod's own 127.0.0.1:18008 in its netns, ALPN h2 / no SNI so it lands on the always-present no-SNI inbound chain, client cert = the node SVID, peer pinned to exactly the pod's SPIFFE ID. Envoy raises Connected only after the TLS handshake, so a pass means "listening, has this pod's certificate, and it verifies as this pod". Inbound validation is untouched: it already requires a client certificate and validates the trust-domain bundle with no SAN restriction, so the node identity is accepted as-is. The gateway filter for the pod requires both clusters; the gateway PATH is unchanged, so the liveness loop and health client are untouched. The probe is not emitted with SPIRE off (cleartext inbound: nothing to prove) or before the node SVID lands (no client certificate) — those pods keep exactly the previous single-cluster gate, so SPIRE-off snapshots are unchanged. The main risk is the other direction: a new Envoy epoch starts every host failed and must re-fetch each pod's SDS secret, so a proxy roll would otherwise demote every pod on the node. The existing warm-up grace does not cover it (it only applies to pods that never served). Two guards: a previously-serving pod is demoted only after 3 consecutive failing observations (15s), and any tick that could not reach the gateway re-arms the full warm-up grace on the next tick that can. Cost: a genuinely dead app is demoted ~10s later; fast local detection is outlier detection, which is unaffected. Per-pod probe clusters use a plain UpstreamTlsContext, never the per-source matcher, so adding one does not perturb any other cluster's bytes. Also: extend the chart's stats exclusions to the new prefix while keeping membership_* (the health_check filter READS those gauges) and ssl.* (the direct read-out of why a pod is stuck un-promoted) readable; runbook section on what HEALTHY now means and how to read a stuck pod; amendment on proposal 004. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
This was referenced Sep 19, 2026
Merged
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.
Discriminator 1 from #638: make the source-side identity binding observable, so the next soak can confirm or kill the hypothesis rather than reasoning about it after the fact.
The hypothesis under test
What reading the generator already settles
The binding is not per-cluster, and the secret name is not independently chosen.
Every mTLS-injected outbound cluster gets the same two pieces of config from
proxy.InjectUpstreamMTLS:transport_socket_matches— one entry per unique local SPIFFE ID (plus the node identity), named by that SPIFFE ID, whose transport socket fetches the SDS secret of the same name (upstreamTransportSocketMatchesNamedpassesidas both the match name andtlsCertificateSecretName).transport_socket_matcher— anexact_match_mapfrom the source pod's netns (theaether.network.network_namespacefilter state,SharedWithUpstream: ONCE) to one of those names, built fromc.localWorkloads.So:
transportsocketmatch.go:89.localWorkloads[netns] → SPIFFE ID. It is byte-identical on every outbound cluster on the node.That second point is itself evidence: it is exactly the field fingerprint. One wrong identity presented toward five distinct clusters within one time slice, "a node-wide constant per time slice, not per-endpoint", is what a wrong entry in this single index looks like. A per-cluster or per-endpoint SDS bug could not produce it.
Where the defect can therefore actually live
The index, not the naming:
c.localWorkloads(guarded bylocalMu) andc.listeners(guarded bylistenerMu) are written non-atomically on the add path (AddPod: listener entry, thensetLocalWorkload), on the remove path (RemovePod: delete listener, thenremoveLocalWorkload), and are merged separately again byLoadListenersFromStorageat agent start — the startup window this defect fires in.The log line goes at that seam.
What lands
agent/internal/xds/cache/identitybinding.go, called fromgenerateSnapshotafter a successfulSetSnapshot, so a logged binding is one Envoy actually received:outbound identity binding—source_pod,source_netns,source_spiffe_id(the identity the cluster will present),pod_spiffe_id(what the owning pod is entitled to, so one line is self-diagnosing),cluster,secret,snapshot_version. Emitted only when that(source pod, cluster)pair changed since the previous snapshot, or on first sight. Steady state is completely silent; the diff is O(pods + clusters) with no cross product unless something moved.outbound cluster bound to a foreign identity+ the new nil-safe OTel counteraether.agent.identity.outbound_binding_mismatch— when the bound secret is not the SPIFFE ID derived from the pod that owns that netns (proxy.SpiffeIDFromPodover the listener entry's ownCNIPod, the API-server-derived truth per security: aether.io/spiffe-id pod annotation is an unvalidated mesh-identity override #669). Fires on the edge only: mismatch status is a function of the binding, so it is reported once per state, never once per snapshot.outbound identity mapping has no owning pod— the other index failure: an identity mapping whose netns no listener entry owns any more, still selectable by whatever stamps that netns next. Not counted as a foreign bind (there is no owning pod to compare against).outbound identity bindings changedcarries the count and the distinct source→identity transitions instead. Only the per-cluster repetition is dropped, and that repetition is redundant by construction.What the line proves or refutes
ssl_fail_verify_sanburst, naming a co-located workload's SVID against a source pod: the hypothesis is confirmed and the bug is the agent-side netns→identity index, with the offendingsnapshot_versionand the exact pod pair in hand.cluster.ssl.fail_verify_sanis a client-side counter about the server's certificate, andupstream_transport_failure_reason=CERTIFICATE_VERIFY_FAILEDis the client rejecting the peer. The inbound path picks its cert directly off each pod's ownCNIPod(ingress.go:75) with no index in between, so if the next run shows no agent-side WARN, the remaining candidate is which pod's inbound filter chain a connection lands on during the startup window.Grep recipe
Then join the WARN's
snapshot_versionagainst the firstenvoy_cluster_ssl_fail_verify_san_totalsample of that proxy generation (max_over_time[6h]on a 60s step — an instant query ages the series out).Also documented in
docs/runbook.md§ 8.Tests
agent/internal/xds/cache/identitybinding_test.go(5 cases): first sight emits exactly one line then repeated snapshots emit nothing; a legitimate re-bind emits exactly one change line and no WARN or counter; a constructed foreign binding emits the WARN with both identities and increments the counter exactly once, staying quiet while the mismatch persists; an orphaned mapping WARNs without counting; and 201 pairs collapse to one summary carrying the transitions.bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //agent/internal/xds/...clean (gocognit included). Nocharts/change, so no chart bump.Refs #638
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr