Skip to content

TCP mesh services are silently unroutable when SPIRE is disabled #877

Closed

Description

@bpalermo

Found while building the kind e2e harness for issue #868 (the TCPRoute leg). Not a
regression — but it is silent, and it costs a day to rediscover.

What happens

With --spire-enabled=false a service classified PROTOCOL_TCP (pod annotation
endpoint.aether.io/protocol: "tcp") has no data path at all, at either end, and
nothing says so:

  • Source. SnapshotCache.captureTCPClusters() (agent/internal/xds/cache/capture.go)
    returns nil unless the node SVID is known:

    if nodeSpiffeID == "" || validationContextName == "" {
        return nil
    }

    SetNodeIdentity is called only by the SPIRE bridge (agent/internal/spire/bridge.go),
    and wireSpireBridge returns early when SPIRE is disabled. So no node SVID ⇒ no
    tcp: clusters are ever published
    . The capture listener still gets its
    cap_tcp_<svc> filter chain (that path is not identity-gated), so Envoy ends up with
    a chain naming a cluster that does not exist.

  • Destination. NewInboundListener(cleartext=true) emits a single default HCM chain
    (buildInboundCleartextFilterChain, agent/internal/xds/proxy/ingress.go). The
    inbound TCP floor chain — what a raw-TCP mesh hop lands on — is built only by
    buildInboundFilterChains, i.e. only on the mTLS path.

Why it matters

e2e/uds.sh and both conformance jobs run SPIRE-off, and that is the obvious template
for any new kind harness. An L4 suite written that way passes its setup, gets a healthy
agent, a Accepted=True TCPRoute, matching filter chains — and every probe fails with a
connection reset and no error stat that names the cause.

Suggested fix

Not necessarily to make it work (TCP-over-mTLS is the design). At minimum make it
loud: when --spire-enabled=false and the capture reconciler classifies at least one
service as TCP, log a WARN naming the service and the consequence, and/or expose a
counter. "Configured, accepted, and silently inert" is the failure mode this repo keeps
paying for.

Filed from the #868 PR2 work; the harness there works around it by installing SPIRE.

Activity

  1. bpalermo commented on Sep 21, 2026

    @bpalermo
    OwnerAuthor

    Fixed in #895 (c8db866).

    What was wrong

    captureTCPClusters gates on a node SVID and a validation context — the TCP floor cluster is built with mTLS, so without identity it returns nothing. generateCaptureListener had no matching gate and emitted cap_tcp_* chains regardless.

    The result was a listener that accepted connections with no cluster behind them. tcp_proxy has no ODCDS cold path, so Envoy killed them silently: no NACK, no stat, nothing distinguishing it from a backend being down. With SPIRE disabled, a mesh looked configured and swallowed every raw-TCP connection to a TCP service.

    What changed

    The chains are gated on exactly the condition the clusters are, factored into one predicate (tcpFloorIdentityReady) so the two cannot drift apart again. The agent WARNs when TCP services are configured but unroutable, rate-limited to once a minute because this is also the normal startup state for a few seconds.

    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, so the caller gets an immediate ECONNREFUSED it can act on.

    The part worth recording

    The first version of this fix was the same bug with the sign flipped, and a test caught it rather than review.

    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. Any node whose TCP services were configured before its SVID would have been permanently unroutable. A gate with no way to reopen is an outage.

    Readiness is now 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.

    Two negative controls, both seen red before landing:

    • a cap_tcp_ chain present with identity absent fails the first subtest — the original bug;
    • removing the reconcile means the chains never come back and the second subtest fails — the inversion.

    Deliberately NOT fixed

    The destination half: the cleartext (SPIRE-off) inbound listener has no TCP floor chain at all, so even with the source side gated, raw TCP has no path without mTLS.

    That is not an oversight — it is the decision recorded in proposal 037: whether raw TCP should ride the mesh without mTLS is a separate question, and the proposal assumes it should not. Closing this issue does not make TCP work with SPIRE disabled; it makes the failure honest instead of silent. If running TCP services without SPIRE is wanted, that deserves its own issue and its own argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions