Skip to content

fix(agent): probe UDP workloads at the mesh inbound port, not their app port - #936

Merged
bpalermo merged 1 commit into
mainfrom
feat/udp-health-probe-v2
Sep 26, 2026
Merged

bpalermo merged 1 commit into
mainfrom
feat/udp-health-probe-v2

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Fixes #931. Fourth of the series, and the one that actually closes the bug.

The mechanism

aether builds each pod's liveness probe as a bare tcp_health_check against its application port. A UDP workload listens on a UDP socket and nothing else, so that connect can never succeed:

tcp_health_check{} on health_<pod> fails forever
  -> health gateway 503 on /healthz/health_<pod>
  -> combineLiveness: "the application decides; the gate never rescues it"
  -> endpoint.Health = HEALTH_UNHEALTHY
  -> endpointHealthStatus stamps UNHEALTHY into the service CLA
  -> UDPLoadAssignment's proto.Clone carries it into the udp: cluster
  -> HealthyPanicThreshold: 0  =>  empty healthy set
  -> udp_proxy drops the datagram

Silently, at every step.

Measured on a live cluster before the fix. nft counters in three netns showed the datagram reaching Envoy's :18001 socket while the upstream forward stayed at 0 everywhere, and udp_proxy's own counter read downstream_sess_rx_datagrams: 1 after four datagrams arrived — it counts only once a session exists, and a session needs a host. Repointing the UDPRoute at a healthy backend made the forward appear with nothing else changed.

The fix, and what it does not claim

NewAppHealthProbeCluster's tcp bool becomes a protocol. A bool had no room for a third state, which is why the gap existed at all.

A UDP pod is probed at the mesh inbound port, which does answer a TCP connect. Be precise about the strength of that: it asserts the pod is up and its proxy is serving, not that the application is reading datagrams. The UDP floor deliberately bypasses the inbound hop, so a wedged UDP listener on a live pod still reads healthy.

It is chosen because it is the only thing about a UDP workload we can actually check — a datagram probe needs a per-service request payload and a per-service notion of a valid reply, and there is no sensible default for an arbitrary UDP protocol. The strong per-pod assertion still happens separately on the pod's own inbound-readiness path, which is TLS and SAN-pinned.

One parser, not two

The caller now reads the protocol through endpointmeta.Protocol — the registry's own parser, the one that decides which key the pod is registered under — instead of comparing the annotation inline.

Those two disagreeing is how #931 stayed invisible: the pod registered one way and was probed another, and nothing compared them.

An unparseable value degrades to HTTP, reproducing what the previous equality check did with anything other than "tcp"; registration rejects it separately and loudly.

The non-UDP direction is pinned too — HTTP, TCP and UNSPECIFIED all still probe the application port — so this cannot quietly redirect every workload's liveness probe away from the app it is meant to check.

Deploy note

This changes how every pod's probe cluster is built, not only UDP ones. The behavioural delta for an existing pod is that the probe protocol now comes from endpointmeta.Protocol rather than an inline == "tcp"; those agree on every value in use today, and "udp" is the only input where they differ. Nothing is annotated protocol: udp yet.

talos-main is eight commits behind and needs this upgrade regardless. I will deploy and verify there after merge — the udp: clusters reporting HEALTHY hosts via the proxy admin is the same query that found the bug — with rollback ready.

Verification

bazel test //... — 109/109, including //test/envoy_validate (stock Envoy validates the composition). Lint clean.

Remaining: PR5 (make the silent drop loud — a udp: cluster with no healthy host should increment something), PR6 (e2e: l4udp-* re-annotated protocol: udp, T3.1 green).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…pp port

This is the fix for #931. A UDP-only workload was permanently UNHEALTHY and
every datagram to it was silently discarded.

THE MECHANISM

aether builds each pod's liveness probe as a bare tcp_health_check against its
APPLICATION port. A UDP workload listens on a UDP socket and nothing else, so
that connect can never succeed:

  tcp_health_check{} on health_<pod> fails forever
    -> health gateway 503 on /healthz/health_<pod>
    -> combineLiveness: "the application decides; the gate never rescues it"
    -> endpoint.Health = HEALTH_UNHEALTHY
    -> endpointHealthStatus stamps UNHEALTHY into the service CLA
    -> UDPLoadAssignment's proto.Clone carries it into the udp: cluster
    -> HealthyPanicThreshold: 0 => empty healthy set
    -> udp_proxy drops the datagram

Silently, at every step. Measured on a live cluster: nft counters showed the
datagram reaching Envoy's :18001 socket while the upstream forward counter
stayed at 0 in all three netns, and udp_proxy's own
downstream_sess_rx_datagrams read 1 after FOUR datagrams arrived -- it counts
only once a session exists, and a session needs a host. Repointing the UDPRoute
at a healthy backend made the forward appear with nothing else changed.

THE FIX, AND WHAT IT DOES NOT CLAIM

NewAppHealthProbeCluster's `tcp bool` becomes a protocol. A bool had no room for
a third state, which is why the gap existed at all.

A UDP pod is probed at the mesh inbound port, which does answer a TCP connect.
Be precise about the strength of that: it asserts the pod is up and its proxy is
serving, NOT that the application is reading datagrams. The UDP floor
deliberately bypasses the inbound hop, so a wedged UDP listener on a live pod
still reads healthy.

It is chosen because it is the only thing about a UDP workload we can actually
check. A datagram probe needs a per-service request payload and a per-service
notion of a valid reply, and there is no sensible default for an arbitrary UDP
protocol. The strong per-pod assertion still happens separately on the pod's own
inbound-readiness path, which is TLS and SAN-pinned.

ONE PARSER, NOT TWO

The caller now reads the protocol through endpointmeta.Protocol -- the registry's
own parser, the one that decides which key the pod is registered under -- instead
of comparing the annotation inline. Those two disagreeing is how #931 stayed
invisible: the pod registered one way and was probed another, and nothing
compared them. An unparseable value degrades to HTTP, reproducing what the
previous equality check did with anything other than "tcp"; registration rejects
it separately and loudly.

The non-UDP direction is pinned too (HTTP, TCP and UNSPECIFIED all still probe
the application port), so this cannot quietly redirect every workload's liveness
probe away from the app it is meant to check.

Fixes #931

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 92430b4 into main Sep 26, 2026
23 checks passed
@bpalermo
bpalermo deleted the feat/udp-health-probe-v2 branch September 26, 2026 00:10
bpalermo added a commit that referenced this pull request Sep 26, 2026
…937)

Fifth of the #931 series. The fix landed in #936; this makes the failure it
fixed detectable if it ever returns in another form.

WHY THERE WAS NOTHING TO SEE

A published udp: cluster in which no endpoint is routable is a silent blackhole.
udp_proxy takes the datagram, finds an empty healthy set (NewUDPServiceCluster
sets HealthyPanicThreshold: 0, so it will not spray to unhealthy hosts), and
discards it. Nothing reports that:

  - no NACK: the config is valid
  - no "UDPRoute input discarded": nothing was dropped at projection time, so
    the #874 path stays quiet
  - no udp_proxy counter either. downstream_sess_rx_datagrams counts per
    SESSION and a session needs a host, so it does not move. Measured on a live
    cluster: it read 1 after FOUR datagrams had reached the socket.

captureUDPClusters is the only place that holds both the cluster and its
endpoints' health, so it is the only place the condition can be named.

Reported rather than skipped. Skipping would remove the listener and trade one
blackhole for another; leaving the cluster published means the service recovers
by itself the moment an endpoint goes healthy.

WHAT COUNTS AS ROUTABLE IS ENVOY'S DEFINITION, NOT OURS

HEALTHY and UNKNOWN are both load balanced -- UNKNOWN is the default for an
endpoint nobody has said anything about -- while UNHEALTHY, DRAINING and TIMEOUT
are not. Reading UNKNOWN as unhealthy would fire on every healthy service whose
endpoints carry no explicit status, which is most of them.

An empty load assignment reports nothing: that is a cold start, not a blackhole,
and firing there would make the counter ring for every service between its
cluster appearing and its endpoints arriving.

THE COUNTER IS SEEDED, AND THE GATE HAS A RED STATE

Seeded at zero, because an unseeded counter has no Prometheus series at all and
"no series" is indistinguishable from "zero" to a grading query. That has been
forgotten twice here (rev200, then rev231/#882) --
TestEveryRegisteredCounterDeclaresItsSeedPolicy now caught it a third time,
before it shipped.

TestUnroutableUDPEndpoints drives the detector red, including the exact shape
#931 shipped in (#853: a gate never shown to fire is not a gate).

INCIDENTAL REFACTOR

New() was one flat run of `if ... err != nil` registrations sitting one
registration below the gocognit limit, so adding this counter failed the lint.
Split into registerActivityInstruments / registerAnomalyCounters /
seedAnomalyCounters -- groups that match the seeding distinction rather than an
arbitrary cut. The seed-policy test parses this file's AST, so it reads the
registrations from the helpers unchanged.

Refs #931


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 26, 2026
)

Fixes #932.

UDPLoadAssignment clone-and-patched the service's SHARED bare-name load
assignment, rewriting exactly two fields (protocol, port) and carrying everything
else through proto.Clone. For a waypointed endpoint that is wrong in a way the
rewrite cannot fix.

src's address for a remote-cluster endpoint is not the pod. The HTTP path
rewrote it to the destination NODE's IP plus the east/west tunnel port (proposal
019) and marked it with waypoint subset metadata. Rewriting only the PORT left
the node IP in place, so the datagram went to a host that was never the backend
-- silently, because the UDP floor has no transport socket and nothing asserts
the reply.

There is no correct address to substitute. The tunnel is a TCP mTLS SNI
forwarder with no datagram counterpart, so a waypointed backend is genuinely
unreachable over the UDP floor. So drop it, which makes the state legible: the
service ends up with no routable endpoint, and that is exactly what
udp_no_healthy_backend counts and logs (#931). A service reachable ONLY through
the waypoint therefore reports itself instead of delivering to the wrong machine.

Two other fields stop surviving the clone:

  Metadata           the udp: cluster sets no LbSubsetConfig, so an envoy.lb
                     subset key is inert -- and an inert subset key on a cluster
                     that does no subset LB invites someone to think it is load
                     bearing.
  HealthCheckConfig  it opts an endpoint out of an ACTIVE health check, and this
                     cluster has none, so it describes a mechanism that does not
                     exist here.

Priority is flattened to 0: without the locality-priority set the HTTP path
builds, a lone endpoint left at a non-zero priority is a cluster whose only host
sits in an empty fallback tier, which Envoy will not use.

HealthStatus DOES still survive, and that is deliberate. Before #936 it was
meaningless here (a TCP probe of a UDP port could only ever fail); now the probe
targets the mesh inbound port, which a UDP pod really does answer, so the verdict
is a real signal.

The tests also pin that src is not mutated -- it is the shared assignment, and
the old code patched the clone but the next reader of that habit might not.


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

1 participant