Skip to content

fix(agent): TCP floor egress must send no SNI (was hitting the inbound HCM → 503) - #306

Merged
bpalermo merged 1 commit into
mainfrom
fix/tcp-floor-no-sni
Jun 24, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/tcp-floor-no-sni

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

With endpoints healthy (#305) and the floor connecting, echo-tcp still 503'd because the inbound HCM handled the connection, not the TCP floor. Cause: captureTCPClusters passed the destination port as SNI (8080), so the inbound per-port HCM chain (server_names:[8080]) out-ranked the inbound floor's default chain. Fix: empty SNI → the no-ALPN floor connection falls to the inbound default floor chain (tcp_proxy → app). Last piece of the floor data path. Validate: echo-tcp → 200.

…d HCM → 503)

With the endpoints healthy (#305) and the floor connecting (upstream_cx_total>0),
echo-tcp still 503'd: the inbound HCM was handling the connection
(listener.inbound.http.inbound.downstream_rq_5xx), not the TCP floor.

Cause: captureTCPClusters passed httpEntry.sni (the destination port, e.g. "8080")
to the TCP floor cluster's transport socket. So the egress floor connection presented
SNI="8080", and the destination inbound's per-port HCM chain (server_names:["8080"])
out-ranks the inbound TCP floor's default chain (Envoy precedence: server_names >
application_protocols > default). The connection landed on the HCM, which can't parse
the raw TCP stream → 503.

Fix: pass an empty SNI for the TCP floor cluster. With no SNI, the no-ALPN floor
connection (post #304) matches no per-port chain and no "h2" chain, so it falls to the
inbound default TCP floor chain (tcp_proxy → app loopback) — the actual passthrough.

This is the last piece of the floor data path (with #305 + #304). Validate on talos:
echo-tcp.aether.internal:18081 (HTTP over the mTLS TCP floor) -> 200.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S
@bpalermo
bpalermo merged commit 10030ae into main Jun 24, 2026
7 checks passed
@bpalermo
bpalermo deleted the fix/tcp-floor-no-sni branch June 24, 2026 22:27
bpalermo added a commit that referenced this pull request Sep 21, 2026
* docs(proposal): multi-protocol ports on one mesh service (037)

A mesh workload is classified HTTP or TCP for the whole pod, and by
extension the whole service: "A service is HTTP or TCP, never both, so the
two sets never share a name" (cache/cluster.go:202). A pod serving an HTTP
API on :8080 and a raw-TCP protocol on :9000 cannot say so, and the mesh
Service is generated per ServiceAccount, so splitting is not an option the
user has.

Draft only -- no code changes, nothing accepted.

The constraint is not the map key. The TCP floor's mesh hop carries no SNI
and no ALPN (deliberately -- #304, #306), so the destination has exactly one
default floor chain and it forwards to the pod's primary port. Fixing the
c.clusters collision alone yields "HTTP ports plus one TCP port", not
multi-TCP-port.

Proposes the per-port model -- a port has a protocol, a service has ports --
by extending the existing endpoint.aether.io/ports suffix grammar with
"=tcp", keeping endpoint.aether.io/protocol as the per-port default so every
current manifest keeps its meaning. Capture chains gain destination_port,
which Envoy evaluates ahead of prefix_ranges and which resolves the
"/32 outranks the HCM catch-all" conflict that forces the invariant today.

Phased so the fix that does not need any of it ships first: Phase 0 is #878
alone (podToEndpoint honours protocol, and populates Ports -- the kubernetes
backend has never carried 005's per-port EDS membership either), on the
existing invariant.

Each risk states what would make its gate fail, with negative controls, and
the two process gates are labelled as such rather than dressed as data-plane
ones (#853).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* docs(proposal): 037 — dedicated TCP mesh port + scheme-typed resolution

Revision from the PR #881 review. The first draft resolved the bare name to
"the primary port, in the primary's protocol", which re-introduced the
asymmetry the proposal exists to remove.

- Add ProxyTCPOutboundPort = 18082 beside 18081 (free tree-wide; the only
  hits are an arbitrary test argument in l4route_test.go). 18081 is HTTP,
  18082 is TCP, for every service.
- A portless URL resolves by its scheme's default port: http:// is 80 and
  HTTP by definition, https:// is 443 and TCP iff the app registered it.
  Raw TCP names its port because it has no scheme. HTTP demuxes on the
  authority header; TCP demuxes on the 5-tuple - that distinction is now
  the justification for the scheme, not a wart.
- http://svc/ needs NO new config: the HCM chain has no destination-port
  criterion and RDS matches the portless authority today. Documented
  intent only. A destination_port:80 chain is listed as rejected.
- http:// to a service with no HTTP port: 421 direct_response vhost with
  x-aether-error, replacing today's unnamed cluster_not_found 503.
- https:// to a mesh service: option (a) refuse deterministically via a
  name-only 443 Service port (kube-proxy REJECT); (b) terminating app TLS
  at the capture listener is scoped out as its own proposal.
- The portless /32 floor chain and its special cases collapse into one
  uniform destination_port chain; :18082 works under scoped capture (CNI
  rule extended), per-app-port TCP still needs redirect-all (two tiers).
- Generated mesh Services expose 18081, 18082 and name-only 80/443, and
  the generator must converge Spec.Ports (it converges annotations only
  today; the MCS clusterset VIP create is create-only).
- New Risk 9: registrar advertises :18082 before a node's agent can serve
  it -> ECONNREFUSED within one RTT, gated by a negative-control e2e.
- "Require a port from every caller" recorded under Alternatives.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* docs(proposal): accept 037 and record Phase 0 as shipped

Phase 0 landed as #888: the kubernetes backend honours
endpoint.aether.io/protocol and populates Ports. Two deviations from the
proposal text, both found in the writing, are recorded in place:

  - the shared parser landed as a leaf package //registry/endpointmeta rather
    than a registry.PortProtocols helper, because //registry/internal/k8s
    importing its parent interface package is the wrong direction;
  - the health-check-mode parser was deliberately NOT shared -- the two
    backends disagree on the UNSET case (EDS vs UNSPECIFIED) and unifying them
    would have silently flipped the CNI registration path.

Also records that only e2e/uds.sh runs on the chart-default kubernetes
backend; every other suite, l4routes.sh included, forces etcd, which is #878's
complaint in harness form.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

---------

Co-authored-by: Claude Opus 5 <[email protected]>
bpalermo added a commit that referenced this pull request Sep 21, 2026
Completes the previous commit. It emitted destination_port-qualified chains
naming tcp:<fqdn>:<port>, but nothing built those clusters -- exactly the
hazard proposal 037 lists as Risk 1.

No service on the cluster has a non-primary TCP port yet, so no such chain is
emitted today and nothing is currently broken. But the registry half already
accepts `=tcp` and registers under both keys, so a user annotating
`ports: "8080,9000=tcp"` would have got a chain pointing at a cluster that does
not exist. tcp_proxy has no ODCDS cold path, so Envoy kills those connections
silently: no NACK, no stat, nothing to distinguish it from a backend that is
down.

Each non-primary TCP port now gets an entry keyed tcp:<fqdn>:<port> with its
OWN load assignment, named <fqdn>:<port> and filtered to the endpoints that
advertise that port AS TCP. Sharing the bare-name EDS would put every pod of
the service in the pool including ones that do not serve the port -- the
per-port membership filter is what makes adding a port to a rolling Deployment
safe, exactly as it already is for HTTP (proposal 005).

These clusters DO carry SNI, unlike the floor. The floor must carry none (#306)
so it lands on the destination's default inbound chain, which forwards to the
pod's primary port. A non-primary port has no such default to fall back on: the
SNI is how the destination demuxes to the right loopback port, and it is safe
precisely because only a post-037 agent advertises such a port -- the same
agent that builds the matching inbound chain.

Adds the gate proposal 037 asks for: resolve every cluster named by any
tcp_proxy, across every listener, single and weighted, against the snapshot's
CDS set. With the per-port clusters suppressed but the chains still emitted --
the exact state of the previous commit -- it fails with

  filter chain "cap_tcp_tcp:multi.aether-test.aether.internal_5432" names
  cluster "tcp:multi.aether-test.aether.internal:5432", which is not in the
  snapshot

which is the bug it exists to catch.

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 21, 2026
… 3b)

The destination half of per-port TCP, and it has to ship WITH the source half
rather than after it.

A raw-TCP port now gets a tcp_proxy chain matched on the port as SNI, instead
of the HCM chain every served port gets today:

  in_tcp_<pod>_<p>:  server_names [<p>]  ->  tcp_proxy -> app_<pod>_<p>

Exactly one of the two per port. Two chains matching the same server_names is a
listener Envoy cannot disambiguate, and it rejects the whole LDS update rather
than the offending chain -- leaving the pod on its previous listener, or
unreachable if it is new.

Why this cannot land separately from the source side: that side sets SNI on a
non-primary TCP port's upstream socket so this chain can match it. Without this
commit, the destination's existing per-port HCM chain matches server_names
["9000"] instead, and a raw-TCP stream lands on an HTTP filter that cannot
parse it. That is the #306 failure mode, reached by shipping half of a
mechanism -- so both halves are in one change.

The PRIMARY port deliberately gets no SNI chain: it is what the default floor
chain already serves, reached by a no-SNI mesh connection (#306), and a chain
for it would be dead config.

A malformed `=tcp` suffix yields no TCP ports rather than a guess, so the pod
keeps the HCM chains it had yesterday. The registration path rejects the same
value outright, so a pod can only reach that state by being annotated after
registration.

Negative control: emitting BOTH chains for a TCP port -- the obvious wrong
implementation -- fails with

  server_names "9000" claimed by both "in_tcp_app-0_9000" and "in_app-0_9000";
  Envoy rejects the whole listener

which is the ambiguity the design exists to avoid.

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 21, 2026
…bound chains (037 Phase 2, Release B part 3) (#895)

* feat(agent): destination_port capture chains from a cache-derived map (037 Phase 2, Release B part 3a)

Per-port raw-TCP capture chains, and the classification move that makes them
possible.

The cache now derives each service's NON-PRIMARY raw-TCP ports from its
endpoints' port_protocols, and the capture listener emits one
destination_port-qualified chain per port, targeting that port's own
tcp:<fqdn>:<port> cluster rather than the floor cluster (the floor forwards to
the pod's PRIMARY port, so routing :9000 through it would deliver that traffic
to :8080).

destination_port is the mechanism the whole proposal turns on. Envoy evaluates
it ahead of prefix_ranges, and use_original_dst -- already set on the capture
listener -- makes it the port the client dialed before the REDIRECT. A chain
matching only the ClusterIP outranks the HCM catch-all's application_protocols
match and swallows the VIP's HTTP traffic, which is precisely why a service
could not be both protocols.

Classification is derived from the ENDPOINTS, not from the mesh Service's
aether.io/app-protocol annotation. That annotation is the registrar's
projection of a per-pod fact, one hop removed from its source, and #878 is what
happens when the two copies disagree. Deriving in the cache means the chain and
the cluster that serves it come from one map in one snapshot generation --
which is also the structural half of #877, since a chain whose cluster was
never built kills connections silently and tcp_proxy has no ODCDS cold path.

The primary port is deliberately excluded: the portless floor chain already
reaches it, so a chain for it would add nothing.

Risk 4, the listener drain, is handled by reusing SetCaptureTCPServices'
existing change detection rather than adding a second trigger. Regenerating a
per-pod capture listener drains its connections, and a registry reload happens
on every pod ADD/DEL anywhere on the node -- so the comparison has to be over
the DERIVED port set, not over the fact that a reload occurred. Derived slices
are sorted, so a rollout that replaces every pod while declaring the same ports
produces an identical slice and regenerates nothing.

Both halves of that are tested, and the negative control is the second one:
removing the port comparison from equalTCPEntries makes the "a real change MUST
regenerate" assertion fail, so the comparison is not decoration.

No behaviour change for any service today: deriving excludes the primary, and a
pod with one declared protocol has exactly one class, so every existing service
yields an empty set and no extra chains.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* feat(agent): build the per-port TCP clusters the capture chains name

Completes the previous commit. It emitted destination_port-qualified chains
naming tcp:<fqdn>:<port>, but nothing built those clusters -- exactly the
hazard proposal 037 lists as Risk 1.

No service on the cluster has a non-primary TCP port yet, so no such chain is
emitted today and nothing is currently broken. But the registry half already
accepts `=tcp` and registers under both keys, so a user annotating
`ports: "8080,9000=tcp"` would have got a chain pointing at a cluster that does
not exist. tcp_proxy has no ODCDS cold path, so Envoy kills those connections
silently: no NACK, no stat, nothing to distinguish it from a backend that is
down.

Each non-primary TCP port now gets an entry keyed tcp:<fqdn>:<port> with its
OWN load assignment, named <fqdn>:<port> and filtered to the endpoints that
advertise that port AS TCP. Sharing the bare-name EDS would put every pod of
the service in the pool including ones that do not serve the port -- the
per-port membership filter is what makes adding a port to a rolling Deployment
safe, exactly as it already is for HTTP (proposal 005).

These clusters DO carry SNI, unlike the floor. The floor must carry none (#306)
so it lands on the destination's default inbound chain, which forwards to the
pod's primary port. A non-primary port has no such default to fall back on: the
SNI is how the destination demuxes to the right loopback port, and it is safe
precisely because only a post-037 agent advertises such a port -- the same
agent that builds the matching inbound chain.

Adds the gate proposal 037 asks for: resolve every cluster named by any
tcp_proxy, across every listener, single and weighted, against the snapshot's
CDS set. With the per-port clusters suppressed but the chains still emitted --
the exact state of the previous commit -- it fails with

  filter chain "cap_tcp_tcp:multi.aether-test.aether.internal_5432" names
  cluster "tcp:multi.aether-test.aether.internal:5432", which is not in the
  snapshot

which is the bug it exists to catch.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* feat(agent): per-port inbound TCP chains (037 Phase 2, Release B part 3b)

The destination half of per-port TCP, and it has to ship WITH the source half
rather than after it.

A raw-TCP port now gets a tcp_proxy chain matched on the port as SNI, instead
of the HCM chain every served port gets today:

  in_tcp_<pod>_<p>:  server_names [<p>]  ->  tcp_proxy -> app_<pod>_<p>

Exactly one of the two per port. Two chains matching the same server_names is a
listener Envoy cannot disambiguate, and it rejects the whole LDS update rather
than the offending chain -- leaving the pod on its previous listener, or
unreachable if it is new.

Why this cannot land separately from the source side: that side sets SNI on a
non-primary TCP port's upstream socket so this chain can match it. Without this
commit, the destination's existing per-port HCM chain matches server_names
["9000"] instead, and a raw-TCP stream lands on an HTTP filter that cannot
parse it. That is the #306 failure mode, reached by shipping half of a
mechanism -- so both halves are in one change.

The PRIMARY port deliberately gets no SNI chain: it is what the default floor
chain already serves, reached by a no-SNI mesh connection (#306), and a chain
for it would be dead config.

A malformed `=tcp` suffix yields no TCP ports rather than a guess, so the pod
keeps the HCM chains it had yesterday. The registration path rejects the same
value outright, so a pod can only reach that state by being annotated after
registration.

Negative control: emitting BOTH chains for a TCP port -- the obvious wrong
implementation -- fails with

  server_names "9000" claimed by both "in_tcp_app-0_9000" and "in_app-0_9000";
  Envoy rejects the whole listener

which is the ambiguity the design exists to avoid.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* fix(agent): gate the TCP capture chains on node identity (#877)

The TCP floor is mTLS-only: captureTCPClusters returns nothing without a node
SVID and a validation context. generateCaptureListener had no matching gate, so
it emitted cap_tcp_* chains regardless — a listener that ACCEPTED connections
with no cluster behind them. tcp_proxy has no ODCDS cold path, so those
connections died silently: with SPIRE disabled a mesh looked configured and
swallowed every raw-TCP connection to a TCP service.

The chains are now gated on exactly the condition the clusters are, factored
into one predicate so the two cannot drift apart again.

Failing CLOSED is deliberate. Building a plaintext TCP floor when identity is
unavailable would be a silent authentication downgrade, the #832/#843 class.
Suppressing the chains instead lets the connection fall to the passthrough and
be REJECTed by kube-proxy at the mesh Service port — an immediate ECONNREFUSED
the caller can act on — and the agent WARNs, rate-limited to once a minute
because this is also the normal startup state for a few seconds.

The gate needed a way to REOPEN, and finding that out is what the test bought.
Identity arrives asynchronously, so a capture listener built before it lands
carries no chains, and SetNodeIdentity only regenerates the snapshot — it does
not rebuild pod listeners. The first version of this change was therefore a
PERMANENT outage for any node whose TCP services were configured before its
SVID: exactly the bug it set out to fix, with the sign flipped.

Readiness is instead reconciled from generateSnapshot, alongside
recomputeInboundReadyClusters and for the reason stated there: the SPIRE bridge
calls SetNodeIdentity exactly once ever (`if firstServe`), so a trigger hanging
off it can be missed permanently — which is how main-worker-05 ran a whole
agent lifetime with no probe clusters on 2026-09-19. A comparison and an early
return in the steady state.

Negative controls, both seen red:
  - with identity absent, a cap_tcp_ chain in the snapshot fails the first
    subtest (the #877 bug itself);
  - with the reconcile removed, the chains never come back and the second
    subtest fails (the permanent-outage inversion).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

---------

Co-authored-by: Claude Opus 5 <[email protected]>
bpalermo added a commit that referenced this pull request Sep 22, 2026
A TCPRoute/TLSRoute backendRef naming a specific raw-TCP port now resolves to
that port's cluster.

common/l4project's ClusterNameFunc takes the backendRef's port. It was
documented as "NOT port-qualified" because the TCP floor addressed one port per
service and a port had nothing to select. Now that a service can carry several
raw-TCP ports, ignoring it would silently send a route for :5432 to whatever
the floor forwards to -- a misroute with no error anywhere.

A ref with no port yields 0 and the service's default floor cluster, which is
what every route written before this change resolves to.

The cache now publishes tcp:<fqdn>:<port> for EVERY TCP port, not only the
non-primary ones. The primary's is an ALIAS: same EDS as the floor and NO SNI,
because the destination's default inbound chain serves it and a non-empty SNI
would route it to a per-port chain that does not exist (#306). Without that
alias a backendRef naming the primary port would resolve to a cluster that is
not in the snapshot, and tcp_proxy would kill those connections silently --
the same Risk 1 shape as a chain without a cluster, reached from the other end.

UDP deliberately keeps ignoring the port: the UDP floor already addresses
backends by their registered application port (proposal 018 Phase 3b), and 037
is a TCP/HTTP change. The parameter is accepted and dropped so the signature is
shared; unifying the two is a later proposal's job.

Negative control: ignoring backendRef.port -- the pre-Phase-3 behaviour --
fails the port-qualified case while the no-port case still passes, which is the
split that matters for the rollout: every existing route is in the second.

NOT included: the GAMMA projector rejecting an HTTPRoute backendRef.port that
resolves to a TCP port (ResolvedRefs=False / UnsupportedProtocol). The proposal
lists it as an open question because ProjectHTTPRule also runs in the
registrar's config-export controller, where there are no endpoints to classify
against. The agent's cache already declines to build an h2 cluster for a TCP
port, so such a route 503s rather than misrouting -- loud, but late.


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Opus 5 <[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