Skip to content

feat(mesh): support non-HTTP (TCP) services end-to-end - #297

Merged
bpalermo merged 1 commit into
mainfrom
feat/tcp-service-model
Jun 24, 2026
Merged

bpalermo merged 1 commit into
mainfrom
feat/tcp-service-model

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Why

PR #294 shipped a transparent-capture TCP-over-mTLS floor and #296 shipped TCPRoute/TLSRoute/UDPRoute L4 routing, but both were unreachable: the service model was HTTP-only, so a workload could never be classified as TCP. This makes a workload registerable/generatable as a PROTOCOL_TCP service so the floor + L4 routes become reachable and e2e-testable.

Goal e2e (parent runs it): an HTTP echo workload annotated tcp is reached via the capture TCP floor as a raw mTLS passthrough (the HTTP request rides the passthrough connection) → HTTP 200.

How an operator marks a workload TCP

Add a pod annotation (a registration fact — what the pod serves):

metadata:
  annotations:
    endpoint.aether.io/protocol: tcp   # default "http"; "tcp" => PROTOCOL_TCP

Unset or http registers a normal HTTP service (unchanged). tcp registers the workload under PROTOCOL_TCP; the registrar then projects a selectorless mesh Service annotated aether.io/app-protocol=tcp, which the agent's capture reconciler reads to emit the per-ClusterIP TCP-proxy floor chain. An unknown value is rejected (no silent mis-registration).

What changed

  • proto (api/aether/registry/v1/service.proto): Service.Protocol PROTOCOL_TCP = 2.
  • registration (registry/cni.go): protocol chosen from endpoint.aether.io/protocol (new constant AnnotationEndpointProtocol + ProtocolHTTP/ProtocolTCP in common/constants/annotations.go).
  • generator (registrar/internal/services/generator.go): iterates every protocol and emits TCP services with appProtocol=tcp; one mesh Service per name (HTTP claimed first), no-clobber convergence preserved.
  • registrar snapshot/sync/server: the sync loop lists+syncs every protocol (new syncedProtocols); write-behind unregister supersedes across protocols (the request carries no protocol; a service is registered under exactly one, and the external delete is protocol-agnostic).
  • agent watch cache (registry/internal/registrar/registrar.go): the watch-fed cache is partitioned by protocol so ListAllEndpoints(protocol) returns only that protocol's services. ListAllEndpoints now gates on watch readiness (first SNAPSHOT_COMPLETE) instead of a non-empty partition, so a protocol with no services returns the truthful empty set instead of falling back to an RPC.
  • agent EDS (agent/internal/xds/cache/cluster.go + cache.go): TCP services get a cluster entry holding only the bare-name EDS load assignment (+ sanNamespaces/sni); the floor's tcp:<svc>.<domain> cluster (built in captureTCPClusters) references that EDS by ServiceName. No HTTP h2 cluster/vhost is emitted for a TCP service (new clusterEntry.tcp flag).
  • ghost sweep (agent/internal/cni/server/ghostsweep.go): reconciles both protocols (new sweptProtocols) so TCP endpoints aren't ghost-pruned.
  • chart: charts/aether/Chart.yaml bumped to 0.38.0.

Tests

  • registry/cni_test.go: registration picks TCP from the annotation (and rejects unknown).
  • registrar/internal/services/generator_test.go: generator emits a tcp-annotated mesh Service.
  • agent/internal/xds/cache/tcp_service_test.go: agent builds a tcp:<svc>.<domain> cluster (EDS service = bare name, per-source mTLS matcher) with the registry endpoint in EDS, and emits no HTTP cluster for it.
  • Existing registrar/sweep/cache test mocks updated to be protocol-aware (HTTP-only fixtures no longer double-count as TCP).

bazel build //..., bazel test //... (59 pass), bazel run //:format, --config=lint all clean.

Design note (called out per task)

The agent's watch-fed RegistrarRegistry cache was keyed by service name only and ListAllEndpoints ignored its protocol argument. The clean generalization is to partition the cache by protocol (the watch stream already carries Protocol per event). HTTP services land in the HTTP partition exactly as before, so HTTP behavior is identical; TCP services get their own partition. This is the one place the protocol partitioning was deeper than a pure additive change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S

PR #294 (TCP-over-mTLS floor) and #296 (TCPRoute/TLSRoute/UDPRoute L4
routing) were both unreachable because the service model was HTTP-only: a
workload could never be classified as TCP. This lets a workload be
registered and generated as a PROTOCOL_TCP service so the capture TCP
floor and L4 routes become reachable and e2e-testable.

- proto: add Service.Protocol PROTOCOL_TCP = 2.
- registration (registry/cni.go): pick the protocol from the new
  endpoint.aether.io/protocol pod annotation (default "http"; "tcp" =>
  PROTOCOL_TCP; unknown values rejected).
- generator: project PROTOCOL_TCP services into selectorless mesh Services
  annotated aether.io/app-protocol=tcp (the agent capture reconciler's
  TCP-floor signal); one mesh Service per name, HTTP claimed first.
- registrar snapshot/sync/server: list + sync every protocol; supersede
  write-behind unregisters across protocols.
- agent watch cache (RegistrarRegistry): partition the watch-fed cache by
  protocol so ListAllEndpoints(protocol) returns only that protocol's
  services; ListAllEndpoints now gates on watch readiness (not a non-empty
  partition) so an empty protocol returns the truthful empty set.
- agent EDS (cache/cluster.go): build TCP service cluster entries holding
  the bare-name EDS load assignment (+ SAN/sni) that the floor's
  "tcp:<svc>.<domain>" cluster references; no HTTP h2 cluster/vhost is
  emitted for a TCP service.
- ghost sweep: reconcile both protocols so TCP endpoints aren't ghost-pruned.

Operator marks a workload TCP with the pod annotation:
  endpoint.aether.io/protocol: tcp

Adds unit tests: registration picks TCP from the annotation; the generator
emits a tcp-annotated mesh Service; the agent builds a tcp:<svc> cluster
with EDS endpoints. HTTP behavior is unchanged (default is HTTP).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S
@bpalermo
bpalermo merged commit 607343d into main Jun 24, 2026
10 checks passed
@bpalermo
bpalermo deleted the feat/tcp-service-model branch June 24, 2026 12:43
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