Repository navigation
fix(agent): make cluster/CLA protos deterministic to stop spurious CDS churn - #135
Merged
Merged
Conversation
…S churn The transport-socket match list injected into every service cluster was built from localWorkloads map iteration, so transport_socket_matches — a repeated field whose order is part of the resource bytes — reshuffled on every snapshot bump. The delta-xDS cache hashes resource bytes (with deterministic marshaling, so only repeated-field order is unstable) to decide what changed: every push therefore sent ALL service clusters as changed, and Envoy logged `cds: N added/updated, skipped 0 unmodified` followed by 15s of `initial fetch timed out` EDS warming on every SVID rotation (~every 1-2 minutes). Observed on talos-main after ~9h of steady state: proxies grew to 1.5-3.5 GiB RSS / ~1 core (a freshly restarted proxy: 95 MiB) from the constant cluster replace + warm cycle under long-lived downstream connections, saturating 4-core worker nodes. The saturation cascaded into kubelet flaps, agent informer-desync liveness kills (13 restarts on one node) and proxy admin-watchdog kills (14 restarts). UpstreamTransportSocketMatches now dedupes and sorts the SPIFFE IDs, so an unchanged workload set always produces byte-identical clusters. CLAs rebuilt from the endpoint map (RemoveEndpoint) or from registry listings (LoadClustersFromRegistry) are likewise sorted by endpoint address so an unchanged endpoint set never hashes as an EDS change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This was referenced Jun 11, 2026
bpalermo
added a commit
that referenced
this pull request
Jun 11, 2026
Live measurement on talos-main found the node proxy leaking upstream mTLS connections: ~41k active upstream connections (13.9k per service cluster) and 3.2 GiB of live heap within minutes of startup, while the outbound listeners showed only 1-2 active downstream connections. Service clusters use connection_pool_per_downstream_connection for per-source mTLS, so every non-keepalive downstream connection creates a dedicated pool with a fresh upstream mTLS H2 connection. When the downstream connection closes, the orphaned pool can never be selected again — and the only mechanism that reclaims its upstream connection is the common HTTP idle timeout, which Envoy defaults to 1 HOUR. Under non-keepalive traffic that plateaus at rate×3600 leaked connections per proxy, far past node capacity; the resulting saturation cascaded into kubelet flaps, agent informer-desync liveness kills and proxy admin-watchdog kills (the steady-state degradation observed alongside, and previously attributed to, the CDS churn fixed in #135). Changes: - Upstream: 30s idle timeout on the HTTP/1 and HTTP/2 protocol options used by service clusters. Orphaned pools are reclaimed in seconds; live downstream connections just re-establish an idle upstream on the next request. - Downstream backstop: 5m idle timeout on the shared per-pod HCM builder (inbound mesh conns + app-side outbound conns), well above the upstream timeout so the client side always disconnects first. - Per-connection buffer limits: 32 KiB (Envoy edge-hardening guidance) on every generated listener and cluster, replacing the 1 MiB/connection/ direction default that turns connection-count incidents into memory incidents. Co-authored-by: Claude Opus 4.8 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Jun 11, 2026
* feat(proxy): overload manager with health-gateway bypass Third layer of the memory-incident defense, after leak prevention (#135/#136) and containment (#137's 1Gi limit): graceful degradation before the limit's OOM kill. A fixed_heap monitor (default 768Mi = 75% of the 1Gi container limit; heap excludes stats/code//dev/shm) drives a shedding ladder: 0.80 shrink_heap 0.90 disable_http_keepalive (sheds idle downstream conns; their per-downstream upstream pools then idle out via the 30s timeout) 0.85-0.95 reduce_timeouts (scales HTTP downstream idle toward 2s - the dynamic version of #136) 0.95 stop_accepting_requests (503s new streams, which client routes retry on a DIFFERENT endpoint - the overloaded node sheds load to other replicas) 0.98 stop_accepting_connections The agent-generated health-gateway listener sets bypass_overload_manager: delegated liveness must report APP truth, not proxy state. Without the bypass an overloaded proxy would 503 the agent's liveness probes and flap every local pod's registry health cluster-wide on transient overload; shedding belongs to the data-plane listeners (503+retry, client active HC), not the liveness channel. The gateway is a node-local UDS with a handful of agent connections, so the exemption frees no meaningful memory. Inert in normal operation: steady-state heap sits far below the first rung. Rendered bootstrap validated with `envoy --mode validate` against the pinned image digest (configuration OK). Gated by proxy.overload.enabled (default true). Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(proxy): drive the overload ladder from cgroup_memory, not fixed_heap The fixed_heap monitor measures tcmalloc heap, but the OOM killer enforces the cgroup limit on the whole container working set — the supervisor process, kernel socket buffers (charged to the cgroup, and correlated with exactly the overload scenario) and thread stacks are all invisible to a heap monitor, which forced a ~75% heap budget of guesswork and a values knob that had to be bumped in lockstep with the memory limit. The cgroup_memory monitor reads memory.current / memory.max directly, so the thresholds sit against the real kill line and the knob disappears (optional maxMemoryBytes only to engage the ladder below the cgroup limit). Verified end-to-end against the pinned Envoy image: listed in the binary's compiled-in resource monitors, --mode validate OK, and a live run under docker --memory=256m reports pressure tracking the limit with zero failed_updates. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Sep 5, 2026
… demand set on a fresh xDS stream (#682) (#698) * fix(xds): publish the ODCDS alias for the service's mesh port(s), not the registry endpoint port (#682) #691 published a cold-path alias cluster "<fqdn>:<port>" so the ODCDS catch-all's cluster_header ":authority" always names a cluster the agent can actually publish. It derived that port from endpoints[0].GetPort() — the REGISTRY endpoint port, which is the APPLICATION port (endpoint.aether.io/port, default 8080). That is not the port a client dials. Mesh DNS answers a portless A record for the mesh VIP Service, and every mesh VIP Service advertises exactly one port: meshconst.ProxyOutboundPort (18081), synthesized by the registrar's Service generator (MeshPort), matched by the CNI's capture dport rule and by the cap_http route domains. So the authority the catch-all sees in production is "<fqdn>:18081" — never the app port — while the alias #691 published was "<fqdn>:8080". Deployment validation on talos-main (rev194, 2026-09-05) confirmed it: the only port-suffixed echo cluster present on a node was echo.aether-test.aether.internal:8080, and no ":18081" cluster existed anywhere in the fleet — the exact name that stalled for 5m10s ("cm odcds: on-demand discovery for cluster echo.aether-test.aether.internal:18081 timed out"). The demand-set-shrink test passed only because #691's TTL exemption kept echo in the dependency set, so the ":18081" path was never exercised. Publish an alias for every port an ODCDS authority can legitimately carry that has no per-port cluster of its own: the mesh port AND the default/application port (the default entry's vhost claims the latter as a host-match domain, so a client dialing it must find a cluster too). A port that IS a real advertised port keeps its own port-filtered per-port cluster — the whole-service alias never shadows it. Order is deterministic (mesh port first) because map order is protocol-visible (#135). TestODCDS_DefaultPortAuthorityIsAnsweredInOnePush now covers both spellings; the new "mesh Service port differs from the app port" case reproduces production (app port 8080, dialed port 18081) and fails on the pre-fix tree with exactly the deployment symptom: map[...]{"echo.aether-test.aether.internal", "…:8080"} does not contain "echo.aether-test.aether.internal:18081" TestLoadClustersFromRegistry_MultiPort gains the mesh-port alias assertions, and TestLoadClustersFromRegistry_MeshPortServedAsRealPort pins the no-shadowing rule. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * fix(xds): answer the first ODCDS miss on a fresh agent without waiting for a periodic tick (#682) Deployment validation of #691 on talos-main (rev194, 2026-09-05) found a ~20s echo outage after every agent restart on the nodes with no local replica: w01: CNI conflist re-assert loop started 13:34:46.317Z observed undeclared upstream (ODCDS miss) echo 13:35:05.052Z (+19s) w03: 13:35:11.650Z -> 13:35:31.669Z (+20s) with prober http_error +130 (w01) / +127 (w03) inside the window, then flat, and the AetherProberHTTPErrorBurst alert firing and resolving. The agent is not slow. Its xDS socket was accepting 1.8s after the anchor (13:34:48.125Z); PreListen did not stall (no "registry watch cache not complete in time", no registry error), the catalog was healthy (no "rejecting on-demand request for unknown service"), and no TTL expiry fired. The access logs pin the outage precisely: exactly 133 x 503 cluster_not_found/NC per node, echo only (uds-echo and uds-cr-echo served 200 throughout), 10 rps to zero at 13:34:51 and back at 13:35:05, request durations capped at 2003ms — the on_demand filter's 2s timeout, ~7 rounds of it. So Envoy WAS trying, and the agent's onDeltaRequest callback saw nothing for 14.05s (w01) / 14.67s (w03). Mechanism: the observed half of the dependency set is process-local memory, so a restarted agent's first snapshot legitimately drops every ODCDS-acquired upstream — which is meant to cost one round trip, except a reconnecting Envoy never re-asks. markStreamFresh() puts every requested resource back into "waiting for server" and CLEARS the pending-add set, and the first request of the new stream carries initial_resource_versions only for resources it HOLDS plus resource_names_subscribe only for names added since. A name it is still waiting on is in NEITHER field, and updateSubscriptionInterest dedupes every later re-subscribe for a name already in requested_resource_state_. Nothing reaches the new agent until Envoy's 15s init-fetch timeout tears that state down and the next request re-subscribes from scratch — hence 14-15s, and hence the agent logging nothing at all for the whole outage. The evidence the agent was ignoring is in the same handshake: initial_resource_versions is the proxy stating, in the protocol, exactly which clusters it is still running on. Re-seed the node dependency set from it on the first request of every delta CDS stream (resumeHeldClusters), so the demand set is recovered BEFORE the first snapshot push and the upstream never leaves the snapshot at all. Restored entries are ordinary TTL'd observations, not live-subscription pins: an upstream the proxy has stopped using still ages out, so demand scoping still shrinks after a restart. They are also not counted as ODCDS misses — the proxy is not asking for something new, the agent is recovering demand it had already granted, and counting them would drown the miss metric (the signal to promote an upstream to an annotation) in one burst per restart. Only plain mesh service clusters are accepted, "<svc>.<ns>.<domain>" with an optional ":<port>" suffix: per-pod app_/health_ clusters, the "tcp:" floor clusters (a lenient match would mint keys like "ns/tcp:svc") and the passthrough cluster are not demand-set entries, and a held name whose service has left the catalog is skipped silently rather than counted as a rejection. Tests: TestOnDemandObserver_ResumesHeldClustersOnAFreshStream (the reconnect handshake with NO named subscribe at all, plus the name filtering and the no-pin rule), TestOnDemandObserver_ResumeIsIdempotentAndFirstRequestOnly, and TestRestoreDependency_AnsweredInTheFirstPushAndStillDecays (the requested authority is in the FIRST push after a restart, and still decays). All three fail with the resume pass stubbed out. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * feat(agent): count TTL-exempted in-use upstreams (#682) #691 stopped expiring an observed dependency the node's proxy still holds a live on-demand subscription for. The exemption's entire effect is that nothing happens — no "expired observed upstreams", no cluster drop, no ODCDS re-warm — and its only trace was a Debug line, so the deployment validator had no way to tell a working exemption from a demand set that simply never aged. Add aether.agent.upstreams.ttl_refreshed, incremented per exempted entry per prune pass alongside the existing aether.agent.upstreams.* instruments, and nil-receiver-safe like the rest of cachemetrics (a no-op for n <= 0, so a prune pass that exempted nothing records nothing). Raise the accompanying log to Info for the same reason: it fires at most once per prune tick and only when an entry actually crossed its TTL. 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]>
bpalermo
added a commit
that referenced
this pull request
Sep 15, 2026
…fore-deletes, derive the handoff test window from the lease TTL (#772) (#778) * fix(registrar): bound the origin-heartbeat lease grant on a peer (#772) (#597) The replicator's per-peer mirror loop could park forever on its very first RPC. `startLease` grants the origin-heartbeat lease with the replicator's long-lived context, and that is the one call in the loop that cannot use a lease-scoped context, because the lease does not exist yet. Every other peer RPC runs on `connCtx`, which the keepalive watchdog cancels when the lease dies — the grant has no such rescue. clientv3 does not bound it either, and the field name suggested otherwise: * `Config.DialTimeout` does NOT bound connection establishment. Client creation has been non-blocking since etcd #21832 (client/[email protected] config.go:36-44 says so outright), so `clientv3.New` returns before a byte has crossed the wire. * `grpc.WaitForReady(true)` is a default call option (options.go:29,62), so an RPC to a peer that accepts the connection and then says nothing waits rather than failing fast. Net effect against an unresponsive peer: `LeaseGrant` blocks, `runPeer` never comes back around, `aether_replicator_mirror_connected` stays false for that peer and nothing retries until the registrar is restarted. The fix gives the grant — and only the grant — a deadline, reusing `DialTimeout` as the peer-connect budget it was always meant to be. The `KeepAlive` stream deliberately keeps the unbounded context: it must live as long as the connection, and its loss is the signal that redials. `DialTimeout` is left at its 5s default in production (`registrar/internal/ cmd/root.go:343` sets none of the tuning fields). Lowering it, as was originally proposed, would be a regression rather than a hardening: clientv3 derives the first keepalive's deadline from it as `DialTimeout+1s` (lease.go:193), so a 500ms dial timeout would also cut the first-keepalive grace from 6s to 1.5s and make spurious "keepalive lost" redials MORE likely under load. That is now written down on the field. `TestReplicator_RetriesAgainstUnresponsivePeer` pins it, and needs no etcd: a listener that accepts and never speaks gRPC, with the retry observed as repeated connections. Verified as a real discriminator — with the deadline removed it fails in 10s with one connection and the client logging "context canceled while waiting for connections to become ready". Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * fix(registrar): re-attach the mirror before pruning it, in bounded txns (#772) (#597) `syncFull` is where a registrar leader handoff actually happens. The successor grants a fresh origin-heartbeat lease and every mirrored key is value-equal but still attached to the PREDECESSOR's lease, so the re-put at replicator.go:268 is the lease hop — and the mirror only survives if it completes inside whatever the predecessor's lease has left. Two things spent that budget badly: * Stale-key pruning ran FIRST, one `Delete` round trip per key, ahead of the puts that actually rescue the mirror. Pruning is cleanup; it can wait behind the hop. * Both loops issued one round trip per key, so a partial failure left some keys migrated to the live lease and the rest riding the dying one out — a mirror observed half-moved, which reads downstream as a hop that "happened late". Now the sync builds the put and delete sets first, commits the puts, then the deletes, each as transactions of at most 128 ops. A batch lands atomically, and the whole set costs one round trip per batch instead of one per key, which is the term that grows with the size of the region's partition. Batched rather than one transaction because the peer enforces `--max-txn-ops` (128 by default) while an own-partition subtree is unbounded: a single transaction would simply fail at scale. Put keys are sorted, so a given input always batches the same way. The sync is observable on the peer one batch at a time, and map iteration order would otherwise move that boundary run to run (same class as #135). Behaviour is unchanged otherwise: the put and delete sets are disjoint by construction (a key is either absent locally, hence deleted, or present, hence a put candidate), so reordering them is safe. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * test(registrar): derive the lease-handoff window from the measured TTL (#772) (#597) `TestReplicator_LeaseHandoffKeepsMirrorAlive` deliberately watches THROUGH the predecessor lease's expiry, so its entire safety margin is that lease's remaining TTL minus the successor's time-to-re-attach. It picked that window as a flat 14s wall-clock from `stop()`, which assumed a lease phase the test does not control: clientv3 refreshes a lease at TTL/3 (client/v3 lease.go:542), so at `stop()` a nominally-10s lease holds anywhere between 6.67s and 10s. The test was therefore asserting against a margin that varied by ~50% run to run, and whether it even reached the expiry it claims to test was luck. It now reads the predecessor's remaining TTL off the peer with `TimeToLive` at the moment of the handoff and watches until that measured expiry plus 3s. No timeout was lengthened; the window is the same size, just derived instead of guessed. Two assertions added while the lease is in hand, both of which the old shape could not make: * the key must end up on a DIFFERENT lease than the predecessor's — the property the test's own comment claims ("if the sync skipped it on value equality alone…") but never actually checked. Surviving the window on the predecessor's lease used to pass. * the predecessor's lease must be gone (`TTL == -1`) once the loop ends, so the test cannot silently degrade into one that stops short of the expiry. No production code changes here. Flake rate: unchanged at zero locally, 20/20 before and after (`--runs_per_test=20`, 23-28s per run), plus 1/1 under `--config=race`. The #597 failures are CI-only and this workstation does not reproduce them, so the 20-run bar confirms no regression rather than a fixed rate; what the change removes is the uncontrolled variable that made the margin unknowable when it does fail. 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]>
bpalermo
added a commit
that referenced
this pull request
Sep 16, 2026
…780) Incident #135 (map-iteration order -> every push re-hashed -> full CDS replace -> RSS cascade) was fixed for clusters and transport-socket matches. The 2026-09-15 review found the same mechanism alive on RDS and three other resource shapes (races report S6/S7). Determinism here is protocol-visible. go-control-plane versions each resource for delta-xDS by hashing its marshalled bytes, and Envoy skips an update only on an unchanged MessageUtil::hash. proto.MarshalOptions{Deterministic:true} canonicalises map fields but preserves repeated-field order exactly as built, so a repeated field assembled by ranging a Go map is a different resource on every push. Audited every `for ... := range <map>` in agent/internal/xds/cache and agent/internal/xds/proxy (86 sites, enumerated with a go/types pass, not grep) for one whose iteration order reaches an emitted resource. Seven needed fixing; the rest either write into another map (set membership, order-free) or feed a helper that already sorts. Fixed, worst first: - cache/capture.go extensionHTTPFilters: the HCM's http_filters union was built by ranging serviceRoutes, serviceChainFilters and serviceInboundFilters. HTTP filter order is the chain's EXECUTION order, so two escape-hatch filters ran in a random order relative to each other, and every per-pod listener re-hashed on each rebuild. - cache/capture.go captureKnownTargets: the redirect-all catch-all's known-target routes came out in map order. Envoy evaluates a virtual host's routes first-match-wins, so map order decided which authority regex won when two services' short-name spellings overlap. - proxy/l4route.go GenerateUDPCaptureListener (S7): the udp_proxy primary cluster was picked by `for _, backends := range udpRoutes { break }`. With two UDPRoute-backed services the pod's UDP listener forwarded to a different backend on each rebuild of identical input. - cache/capture.go captureVhosts and cache/cluster.go clustersEndpointsAndVhosts (S6): cap_http and aether_outbound RouteConfiguration.virtual_hosts, built by ranging c.captureAuthorities / gammaRoutes / c.clusters. cap_http is the primary client route table on a capture-enabled node. - config/common.go TypedConfig: an Any freezes its payload bytes at construction, so the enclosing resource's deterministic marshal cannot canonicalise what is inside it. The aether_stats TypedStruct carries a structpb.Struct (a proto map) on EVERY per-pod HCM, so every inbound, outbound and capture listener hashed differently on each regeneration. Marshal the Any deterministically. Found by the new test, not by the review. - cache/cluster.go VirtualHosts, cache/listener.go meshListeners and appClusters, cache/snapshot.go secrets: the per-type resource slices. These are name-indexed by go-control-plane so their order is not protocol-visible, but sorting them makes the emitted resource set canonical and is what lets the regression test compare bytes at all. Left unsorted on purpose: every dependency-set/route-domain/effective- route builder (map -> map, so order cannot escape), the identity-binding and inbound-identity-binding collectors (log-only, and they already sort their own output), observedUpstreamsLocked (already sorts), the localWorkloads SPIFFE-ID lists (UpstreamTransportSocketMatches sorts them), AppPortsFromPod and SortSubsetKeys (already sort), the waypoint builders (already sort), the endpoint subset metadata and the cluster's transport_socket_matcher exact_match_map (proto maps NOT inside an Any, so MarshalResource canonicalises them). New: cache/ordering.go with the two sort helpers and the rationale, and TestSnapshotDeterministic_ShuffledInputOrder, which builds a fully populated mesh-mode cache 12 times from shuffled inputs and requires byte-identical proto output for every resource type plus every builder slice. Verified it FAILS on the pre-fix tree: reverting the production changes fails 5/5 runs (on cap_http/aether_outbound RouteConfiguration, appClusters, endpoints and captureVhosts), and reverting only the UDP primary-cluster pick fails on the Listener type. With the fixes it passes 20/20. No resource contents change, only ordering. Verification: bazel build //... //test/e2e:e2e_test; bazel test //... (98/98 pass, including //test/envoy_validate:envoy_validate_test, which runs the pinned proxy Envoy over the generated bootstraps); bazel run //:format.check; bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...; bazel run //:gazelle (no churn beyond the two new files); bazel mod tidy idempotent; scripts/go-deps-audit.sh exit 0. 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 19, 2026
… 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
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
Closed
bpalermo
added a commit
that referenced
this pull request
Sep 20, 2026
…reuse depends on (#852) aether is safe today, and documentation-only — no behaviour changes. But #852's two premises are both wrong at the pinned Envoy (1.40.0-dev.20260904.13144fb), so the comment records what the source actually says rather than what the issue assumed. Correction 1: initial_fetch_timeout is EXEMPT from the RDS reuse key, not "the first field released into it". addDynamicProvider releases config_source.initial_fetch_timeout before MessageUtil::hash and restores it after (source/common/rds/route_config_provider_manager.h:47-54), so two listeners differing only there still share one provider. #839's field is the one addition that could never have split anything. The exemption is RDS-only: scoped RDS, ECDS and ODCDS hash it in. Correction 2: a map-typed field cannot split a provider. MessageUtil::hash is DeterministicProtoHash::hash on any normal build (utility.cc:166-172) — a reflection walk, not a serialisation — and it folds map entries with ADDITION precisely so order cannot matter (deterministic_hash.cc:78-100). Repeated NON-map fields ARE walked in order and are hash-significant. So the live Envoy-side hazard is a repeated field built by ranging a Go map (ConfigSource.authorities, api_config_source's grpc_services / initial_metadata / config_validators) or a genuine semantic divergence between call sites — not serialisation skew. Maps stay a go-control-plane-side snapshot-version hazard, which is #135's mechanism, currently closed by the Deterministic marshals in TypedConfig and cache MarshalResource. Blast radius, likewise corrected. It is NOT doubled RDS traffic: ads:{} resolves to the one process-wide ADS mux, which rebuilds resource_names through a dedup set on every request (grpc_mux_impl.cc:178-190), so the cost is a single redundant DiscoveryRequest at addWatch and zero steady-state bytes. It is NOT a new stat series where the HCM stat_prefixes match: the allocator dedupes by stat name (allocator.cc:299-316), so one series reads DOUBLE — which is aether's case for out_http and cap_http, whose stat_prefixes are the constants "outbound_http" and "capture_http", while the per-Gateway edge listeners take theirs from the listener name and would split into two trees. The unambiguous signal is /config_dump, where dumpRouteConfigs emits one dynamic_route_configs entry per provider. The real costs are two parsed route tables per worker, a second parse/build per push, and independent warming. No NACK and no warning is right. Adds three guards, all confirmed red before landing: - TestConfigSourceBytesIdenticalAcrossConstructions: twelve independent constructions of every ConfigSource this package hands out must serialise identically. Uses a PLAIN proto.Marshal deliberately — Deterministic:true canonicalises map fields and would go quiet on half of what this is for. - TestConfigSourceCarriesNoMapField: walks the populated message tree and fails on any set map-typed field, which the byte comparison misses for a one-entry map. - TestOutboundChainRDSIdenticalAcrossPods: two pods differing in every field the chain builder reads must produce a byte-identical out_http Rds. Deliberately stricter than Envoy's own key. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 20, 2026
…reuse depends on (#852) aether is safe today, and documentation-only — no behaviour changes. But #852's two premises are both wrong at the pinned Envoy (1.40.0-dev.20260904.13144fb), so the comment records what the source actually says rather than what the issue assumed. Correction 1: initial_fetch_timeout is EXEMPT from the RDS reuse key, not "the first field released into it". addDynamicProvider releases config_source.initial_fetch_timeout before MessageUtil::hash and restores it after (source/common/rds/route_config_provider_manager.h:47-54), so two listeners differing only there still share one provider. #839's field is the one addition that could never have split anything. The exemption is RDS-only: scoped RDS, ECDS and ODCDS hash it in. Correction 2: a map-typed field cannot split a provider. MessageUtil::hash is DeterministicProtoHash::hash on any normal build (utility.cc:166-172) — a reflection walk, not a serialisation — and it folds map entries with ADDITION precisely so order cannot matter (deterministic_hash.cc:78-100). Repeated NON-map fields ARE walked in order and are hash-significant. So the live Envoy-side hazard is a repeated field built by ranging a Go map (ConfigSource.authorities, api_config_source's grpc_services / initial_metadata / config_validators) or a genuine semantic divergence between call sites — not serialisation skew. Maps stay a go-control-plane-side snapshot-version hazard, which is #135's mechanism, currently closed by the Deterministic marshals in TypedConfig and cache MarshalResource. Blast radius, likewise corrected. It is NOT doubled RDS traffic: ads:{} resolves to the one process-wide ADS mux, which rebuilds resource_names through a dedup set on every request (grpc_mux_impl.cc:178-190), so the cost is a single redundant DiscoveryRequest at addWatch and zero steady-state bytes. It is NOT a new stat series where the HCM stat_prefixes match: the allocator dedupes by stat name (allocator.cc:299-316), so one series reads DOUBLE — which is aether's case for out_http and cap_http, whose stat_prefixes are the constants "outbound_http" and "capture_http", while the per-Gateway edge listeners take theirs from the listener name and would split into two trees. The unambiguous signal is /config_dump, where dumpRouteConfigs emits one dynamic_route_configs entry per provider. The real costs are two parsed route tables per worker, a second parse/build per push, and independent warming. No NACK and no warning is right. Adds three guards, all confirmed red before landing: - TestConfigSourceBytesIdenticalAcrossConstructions: twelve independent constructions of every ConfigSource this package hands out must serialise identically. Uses a PLAIN proto.Marshal deliberately — Deterministic:true canonicalises map fields and would go quiet on half of what this is for. - TestConfigSourceCarriesNoMapField: walks the populated message tree and fails on any set map-typed field, which the byte comparison misses for a one-entry map. - TestOutboundChainRDSIdenticalAcrossPods: two pods differing in every field the chain builder reads must produce a byte-identical out_http Rds. Deliberately stricter than Envoy's own key. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 20, 2026
…reuse depends on (#852) (#857) aether is safe today, and documentation-only — no behaviour changes. But #852's two premises are both wrong at the pinned Envoy (1.40.0-dev.20260904.13144fb), so the comment records what the source actually says rather than what the issue assumed. Correction 1: initial_fetch_timeout is EXEMPT from the RDS reuse key, not "the first field released into it". addDynamicProvider releases config_source.initial_fetch_timeout before MessageUtil::hash and restores it after (source/common/rds/route_config_provider_manager.h:47-54), so two listeners differing only there still share one provider. #839's field is the one addition that could never have split anything. The exemption is RDS-only: scoped RDS, ECDS and ODCDS hash it in. Correction 2: a map-typed field cannot split a provider. MessageUtil::hash is DeterministicProtoHash::hash on any normal build (utility.cc:166-172) — a reflection walk, not a serialisation — and it folds map entries with ADDITION precisely so order cannot matter (deterministic_hash.cc:78-100). Repeated NON-map fields ARE walked in order and are hash-significant. So the live Envoy-side hazard is a repeated field built by ranging a Go map (ConfigSource.authorities, api_config_source's grpc_services / initial_metadata / config_validators) or a genuine semantic divergence between call sites — not serialisation skew. Maps stay a go-control-plane-side snapshot-version hazard, which is #135's mechanism, currently closed by the Deterministic marshals in TypedConfig and cache MarshalResource. Blast radius, likewise corrected. It is NOT doubled RDS traffic: ads:{} resolves to the one process-wide ADS mux, which rebuilds resource_names through a dedup set on every request (grpc_mux_impl.cc:178-190), so the cost is a single redundant DiscoveryRequest at addWatch and zero steady-state bytes. It is NOT a new stat series where the HCM stat_prefixes match: the allocator dedupes by stat name (allocator.cc:299-316), so one series reads DOUBLE — which is aether's case for out_http and cap_http, whose stat_prefixes are the constants "outbound_http" and "capture_http", while the per-Gateway edge listeners take theirs from the listener name and would split into two trees. The unambiguous signal is /config_dump, where dumpRouteConfigs emits one dynamic_route_configs entry per provider. The real costs are two parsed route tables per worker, a second parse/build per push, and independent warming. No NACK and no warning is right. Adds three guards, all confirmed red before landing: - TestConfigSourceBytesIdenticalAcrossConstructions: twelve independent constructions of every ConfigSource this package hands out must serialise identically. Uses a PLAIN proto.Marshal deliberately — Deterministic:true canonicalises map fields and would go quiet on half of what this is for. - TestConfigSourceCarriesNoMapField: walks the populated message tree and fails on any set map-typed field, which the byte comparison misses for a one-entry map. - TestOutboundChainRDSIdenticalAcrossPods: two pods differing in every field the chain builder reads must produce a byte-identical out_http Rds. Deliberately stricter than Envoy's own key. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Opus 5 <[email protected]>
This was referenced Sep 20, 2026
bpalermo
added a commit
that referenced
this pull request
Sep 23, 2026
… (#914) udp_proxy carries ONE cluster, and the per-pod UDP capture listener was choosing it with `backends[0]` of the lexicographically first service. Two of the three things that discarded were bugs, not limits: - an explicit weight 0 is a Gateway API DRAIN (#492, shipped for TCP and TLS) and the UDP path forwarded to the drained backend anyway; - which backend won depended on backendRef ORDER, so a 10/90 split written canary-first sent 100% to the canary. Both are fixed: drained backends are never bound, a service whose every backend is drained contributes nothing rather than capturing the listener, and among what is left the heaviest backend wins with ties broken by cluster name (#135 — a selection that varies between rebuilds of identical input re-hashes the listener on every push). A genuine traffic SPLIT stays unrepresentable, and this states why instead of faking it. Verified against Envoy v1.39.0: udp_proxy's route action registry is keyed on its own private RouteActionContext and holds exactly one action, `Route`, whose only field is `cluster`. tcp_proxy's weighted_clusters has no counterpart. So does per-service selection, for a reason #873 does not mention and which rules out its suggested fix direction. The capture path REDIRECTs UDP, which rewrites the destination before delivery; a datagram listener's only addressing cmsg is IP_PKTINFO, so a matcher's DestinationIPInput reads the post-DNAT header and the ClusterIP is gone. Envoy never reads IP_ORIGDSTADDR anywhere and original_dst is structurally TCP-only. DestinationPortInput is not packet-derived at all — the port is stamped from the listening socket's own port. A udp_proxy matcher therefore has nothing to discriminate on; that needs TPROXY capture or a listener per service, which is a CNI change. Also closes a dangling-cluster hole found on the way, of the same class as proposal 037 Risk 1 and #877: captureUDPClusters skips a backend service the cluster cache does not hold, but the generator would still name its cluster, and udp_proxy has no on-demand cluster path — the datagrams are accepted and dropped in silence. Both sides now consult one predicate (udpClusterForLocked), so the listener and CDS cannot disagree, and reconcileUDPCaptureListeners rebuilds on snapshot push when the bindable cluster changes, so a UDPRoute landing before its backend registers does not stay dark until the next UDPRoute event. The detector #874 added is no longer a duplicate of the selection it reports on: both call selectUDPRoute, so the drift that test was pinning is now unrepresentable. The test stays as the end-to-end pin. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Opus 5 <[email protected]>
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.
Investigation (talos-main, ~9h after the post-#133 e2e)
Found while digging into the worker-04 Phase 0 outage: the cluster had live failures in steady state —
aether-agenton worker-02: 13 restarts (kubelet liveness kills onhealthz check failed: "cache-sync": informer cache not synced)aether-proxyon worker-02: 14 restarts (supervisor admin watchdog:envoy admin 127.0.0.1:9901 unresponsive for 30s with child alive)The churn engine, visible in every proxy log on every SVID rotation (~every 1–2 min):
Root cause
clustersEndpointsAndVhostsbuilds the SPIFFE-ID list fromlocalWorkloadsmap iteration and injects it into every service cluster astransport_socket_matches— a repeated field whose order is part of the resource bytes. go-control-plane's delta cache hashes resource bytes (deterministic marshaling, so proto map fields are stable — repeated-field order is the only instability) to decide what changed. Result: every snapshot bump reshuffled the field → all service clusters hash as changed on every push → full CDS replace + 15s EDS warming cycle, forever. Under long-lived downstream connections (connection_pool_per_downstream_connection: true) the constant cluster replacement accumulates state — the observed multi-GiB growth — and the resulting node saturation cascades into the informer-desync agent kills and admin-watchdog proxy kills above.Fix
UpstreamTransportSocketMatchesdedupes and sorts the SPIFFE IDs: unchanged workload sets now produce byte-identical clusters.RemoveEndpoint) or from registry listings (LoadClustersFromRegistry) are sorted by endpoint address (SortLocalityLbEndpoints) so an unchanged endpoint set never hashes as an EDS change.Testing
TestUpstreamTransportSocketMatchesDeterministic: shuffled/duplicated inputs produce byte-identical (proto.Equal), sorted matches.TestSortLocalityLbEndpoints: address ordering + nil/empty safety.bazel test //...: 38/38 pass.After merge, the validation signal on talos-main is the disappearance of the recurring
cds: 8 added/updatedblocks in proxy logs and flat proxy RSS over hours.🤖 Generated with Claude Code