Skip to content

fix(registry): honour endpoint.aether.io/protocol on the kubernetes backend (#878) - #888

Merged
bpalermo merged 1 commit into
mainfrom
fix/878-k8s-registry-protocol
Sep 21, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/878-k8s-registry-protocol

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Closes #878.

The bug

ListEndpoints/ListAllEndpoints returned nil for every PROTOCOL_TCP query, so a pod annotated endpoint.aether.io/protocol: tcp was accepted at registration and silently dropped on read. On the chart-default backend that means Accepted=True on the user's TCPRoute and no endpoints, with nothing said anywhere.

The blanket return was a workaround, and its own comment admitted as much. The actual cause was a layer down: podToEndpoint never read the protocol annotation. Every managed pod therefore looked like an HTTP endpoint, and answering a TCP query with that same set made every mesh service collapse to a TCP-only entry — LoadClustersFromRegistry overwrites the HTTP cluster and GAMMA cap_http vhost with a vhost-less tcp:true entry, and captured requests 503'd with no_healthy_upstream (#430). Suppressing the TCP listing hid the symptom; reading the annotation removes the cause.

What changed

Both listings filter on the protocol each pod declares, in both directions. Returning HTTP pods under TCP is #430; returning TCP pods under HTTP is the same bug mirrored, and would put a raw-TCP pod behind an h2 cluster.

The "a service is HTTP or TCP, never both" invariant is untouched and still holds, because every pod behind one ServiceAccount carries the same annotation. RequireProtocolDisjoint keeps passing — and now has a call site where both maps are non-empty, which is the only shape in which it can fail. Its existing call site runs the loop body zero times; that is now noted in place rather than left to look like coverage.

A second missing parser, same cause

podToEndpoint never read endpoint.aether.io/ports either. Ports was nil on every endpoint this backend returned, so proposal 005's per-port EDS membership has never worked here while working fine on the write-based backends. Nobody had hit it, but it is the same defect wearing a different hat.

Both omissions came from one thing: two copies of the annotation parsers that drifted by omission rather than disagreement. A missing parser is invisible in a way a wrong one is not — nothing fails, the field is simply zero. So the parsers move to a shared leaf package, //registry/endpointmeta, following the //registry/export precedent.

One parser deliberately did NOT move

The health-check mode. The two readings genuinely differ on the unset case:

unset annotation //registry (CNI path) //registry/internal/k8s
default EDS UNSPECIFIED

The CNI path defaults to EDS because delegated liveness is its default; this backend must default to UNSPECIFIED, because it derives endpoints from the API server and the delegated active-HC path applies only to the write-based backends. Unifying them — which is exactly what a tidy-minded dedup would have done — would have silently flipped the CNI registration path in production. Both sides now carry a note saying not to.

Risk

No behaviour change for the existing fleet. With no protocol annotation a pod is HTTP, which is what every managed pod on talos-main is today, so the TCP listing stays empty exactly as it was. The change only becomes visible once somebody annotates a pod tcp — which is the thing that is currently broken.

Negative controls

Both halves were seen red before landing, not asserted by inspection:

  • Restoring the blanket TCP short-circuit fails 2 subtests of TestListEndpointsFiltersByPodProtocol — tcp_pod_is_returned_for_a_TCP_query and mixed_pods_split_cleanly:_TCP_side. Only those two: the mirror-direction cases pass either way, which is correct and is why the count matters.
  • Setting Ports back to nil fails 11 subtests.

My first attempt at the second control was inconclusive — removing the field left ports unused, so it was a compile error rather than a test failure. Redone so the assertion actually runs.

Verification

//registry/..., //agent/internal/cni/..., //agent/internal/xds/..., //registrar/... all pass; bazel build //... clean (so nogo is happy); --config=lint --@aspect_rules_lint//lint:fail_on_violation clean; no gazelle drift.

Existing test coverage for the moved parsers was repointed at endpointmeta, not deleted.

Relationship to #881

This is Phase 0 of proposal 037 and is deliberately independent of it: it fixes #878 on the existing invariant, needs no design decision, and nothing here presumes the multi-protocol direction is accepted.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…ackend

The kubernetes backend returned nil for every PROTOCOL_TCP query, so a pod
annotated `endpoint.aether.io/protocol: tcp` was accepted at registration and
silently dropped on read. On the chart-default backend the operator saw
Accepted=True on their TCPRoute and no endpoints, with no diagnostic (#878).

The blanket return was a workaround, not a property of Kubernetes, and its own
comment said so. The real cause was one layer down: podToEndpoint never read
the protocol annotation, so every managed pod looked like an HTTP endpoint and
answering a TCP query with that same set made every mesh service collapse to a
TCP-only entry -- LoadClustersFromRegistry overwrites the HTTP cluster + GAMMA
cap_http vhost with a vhost-less tcp:true entry, and captured requests 503'd
(#430). Reading the annotation removes the need for the workaround.

Both listings now filter on the pod's declared protocol, in BOTH directions:
returning HTTP pods under TCP is #430, and returning TCP pods under HTTP is the
same bug mirrored. "A service is HTTP or TCP, never both" still holds, because
every pod behind one ServiceAccount carries the same annotation, so
RequireProtocolDisjoint keeps passing -- and now has a call site where both
maps are non-empty and it can actually fail.

Also fixes a second missing parser found alongside it: podToEndpoint never read
endpoint.aether.io/ports either, so Ports was nil on every endpoint this
backend returned and proposal 005's per-port EDS membership silently did
nothing here while working on the write-based backends.

Both omissions had one cause -- two copies of the annotation parsers that
drifted by OMISSION rather than disagreement -- so the parsers move to a shared
leaf package, //registry/endpointmeta, alongside //registry/export.

The health-check mode deliberately does NOT move. The two readings differ on
the UNSET case and the difference is load-bearing: the CNI path defaults to EDS
(delegated liveness is its default) while this backend must default to
UNSPECIFIED, because it derives endpoints from the API server and the delegated
active-HC path applies only to the write-based backends. Unifying them would
have silently flipped the CNI registration path in production. Both sides now
say so.

No behaviour change for the existing fleet: with no protocol annotation a pod
is HTTP, which is what every managed pod is today, so the TCP listing stays
empty exactly as before.

Negative controls, both seen red before landing:
  - restoring the blanket TCP short-circuit fails 2 subtests of
    TestListEndpointsFiltersByPodProtocol (and only those -- the
    mirror-direction cases pass either way, as they should);
  - setting Ports back to nil fails 11 subtests.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit b9952eb into main Sep 21, 2026
22 checks passed
@bpalermo
bpalermo deleted the fix/878-k8s-registry-protocol branch September 21, 2026 11:50
bpalermo added a commit that referenced this pull request Sep 21, 2026
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
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]>
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.

endpoint.aether.io/protocol: tcp is silently downgraded to http on the kubernetes registry backend

1 participant