Skip to content

feat(registry): carry per-port protocol on the endpoint (037 Phase 2, Release B part 1) - #892

Merged
bpalermo merged 2 commits into
mainfrom
feat/037-phase2b-registry-port-protocols
Sep 21, 2026
Merged

bpalermo merged 2 commits into
mainfrom
feat/037-phase2b-registry-port-protocols

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Proposal 037 Phase 2, Release B part 1 — the registry half. Follows #890 (Release A, deployed to talos-main as rev232).

What ships

  • map<uint32, PortProtocol> port_protocols = 12 on ServiceEndpoint (edition 2023, IMPLICIT presence, additive). A port present in ports but absent here takes the protocol of the endpoint's registry key — the pre-037 whole-pod classification kept as the per-port default. An endpoint written by an older agent therefore means exactly what it always meant, and readers must tolerate absence.
  • endpointmeta.PortProtocols parses the extended suffix grammar, "8080,9090=h2,9000=tcp". An unsuffixed port inherits the pod-level endpoint.aether.io/protocol — which is why that annotation is kept rather than deprecated. It becomes the default for the port set, so every existing manifest is unchanged.
  • Both construction paths populate it from the same parser: the CNI registration path and the Kubernetes backend's podToEndpoint. They must not drift again (endpoint.aether.io/protocol: tcp is silently downgraded to http on the kubernetes registry backend #878).

The proposal's spec didn't compile

It specified map<uint32, Service.Protocol>. That's a circular import: service.proto already imports endpoint.proto, because a Service carries its endpoints.

I declared a top-level PortProtocol enum with identical values instead. TestPortProtocolMatchesServiceProtocol pins the correspondence — including the value count, so adding a value to one and not the other fails — because nothing in the proto system enforces it and every conversion relies on it.

Unifying them properly means moving Protocol out of Service, which renames registryv1.Service_Protocol at 441 sites across 47 files. That's worth doing on its own, not folded into a feature diff where it would hide the feature.

Two vocabulary decisions

grpc is not accepted as a suffix. gRPC is h2 on the wire and the mesh does nothing gRPC-specific at L4, so accepting it would advertise a distinction the data plane doesn't make. h1 and h2 both map to HTTP here — the codec is an agent-local loopback concern the registry doesn't carry.

An unrecognised suffix is an error, not a default. Defaulting is how a typo becomes a port silently served over the wrong protocol, which is the failure this proposal exists to remove. Note the agent-side AppPortProtocols does default an unknown suffix to HTTP/1.1 today — that asymmetry is Release B part 2's problem.

Deliberately NOT included

Dual registration and dual promotion. A pod serving both classes still registers under its pod-level protocol only, so its TCP port isn't in the TCP listing yet. The field is populated and carried; nothing consumes it for keying.

They're held back because they touch four call sites (pod.go, termination.go, liveness.go, ghostsweep.go) and carry Risk 5: promoting health under one key leaves the other UNHEALTHY forever, with no error — the cluster is simply empty of healthy hosts. That deserves its own diff and its own contract test.

Verification

bazel build //... clean, 57 tests pass, lint clean, deps-audit OK.

New coverage: the suffix grammar (including both error paths), the protocol-set derivation that dual registration will key off, the enum correspondence, and the CNI construction path asserting a mixed pod's map. Existing k8s fixtures were extended rather than weakened.

Release A is live

rev232 on talos-main, 19/19 Ready, 0 restarts — and the migration fix is proven on Services created months ago: all 14 mesh Services converged to mesh=18081 mesh-tcp=18082 http=80 https=443, zero drift. Without that fix they'd have kept their single port and the new spellings would have worked only on a fresh install.

One limit worth stating: the CNI's 18082 redirect can't be verified at runtime from here. The plugin runs as a binary invoked by containerd rather than in the agent pod, and kubectl exec is denied, so the live nftables ruleset isn't readable. The unit test pins the encoded dport (0x46a2); runtime confirmation arrives with Release B part 2, when a chain actually matches it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 2 commits September 21, 2026 11:21
… Release B part 1)

The registry half of Release B: ServiceEndpoint now records the L4 class of
each advertised port, and the shared parser understands the `=tcp` suffix that
declares it.

  - `map<uint32, PortProtocol> port_protocols = 12` on ServiceEndpoint
    (edition 2023, IMPLICIT presence, additive). A port present in `ports` but
    absent here takes the protocol of the endpoint's registry KEY -- the
    pre-037 whole-pod classification, kept as the per-port default -- so an
    endpoint written by an older agent means exactly what it always meant and
    readers must tolerate the field's absence.
  - endpointmeta.PortProtocols parses the extended suffix grammar:
    "8080,9090=h2,9000=tcp". An unsuffixed port inherits the pod-level
    endpoint.aether.io/protocol, which is why that annotation is KEPT rather
    than deprecated -- it becomes the default for the port set and every
    existing manifest is unchanged.
  - Both construction paths populate it from the same parser: the CNI
    registration path and the kubernetes backend's podToEndpoint. The two must
    not drift again (#878).

The proposal specified `map<uint32, Service.Protocol>`, which does not compile:
service.proto already imports endpoint.proto (a Service carries its endpoints),
so referencing Service.Protocol from ServiceEndpoint is a CIRCULAR import.
Declared a top-level PortProtocol enum with identical values instead.
TestPortProtocolMatchesServiceProtocol pins the correspondence -- including the
value COUNT, so a value added to one and not the other fails -- because nothing
in the proto system enforces it and every conversion between them relies on it.
Unifying properly means moving Protocol out of Service, which renames
registryv1.Service_Protocol at 441 sites across 47 files; that is worth doing
on its own, not folded into a feature diff where it would hide the feature.

`grpc` is deliberately not an accepted suffix: gRPC is h2 on the wire and the
mesh does nothing gRPC-specific at L4, so accepting it would advertise a
distinction the data plane does not make. h1 and h2 are both HTTP here -- the
codec is an agent-local loopback concern the registry does not carry.

An unrecognised suffix is an ERROR, not a default. Defaulting is how a typo
becomes a port silently served over the wrong protocol, which is the failure
this proposal exists to remove.

NOT included, deliberately: dual registration and dual promotion. A pod serving
both classes still registers under its pod-level protocol only, so its TCP port
is not yet in the TCP listing. Those touch four call sites and carry the
half-promotion risk (037 Risk 5: promoting health under one key leaves the
other UNHEALTHY forever, with no error -- the cluster is simply empty of
healthy hosts). They land next, on their own.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit d6cb1c9 into main Sep 21, 2026
22 checks passed
@bpalermo
bpalermo deleted the feat/037-phase2b-registry-port-protocols branch September 21, 2026 14:37
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