Skip to content

UDPRoute ignores backend weights and collapses multiple services onto one cluster #873

Closed

Description

@bpalermo

Found while planning #868's e2e coverage. Filing separately per one-issue-per-finding — this is a control-plane correctness limit, not test debt.

What the code does

GenerateUDPCaptureListener (agent/internal/xds/proxy/l4route.go:186-206) builds one UDP listener per pod whose RouteSpecifier is a bare Cluster:

var primaryCluster string
for _, svc := range slices.Sorted(maps.Keys(udpRoutes)) {
	if backends := udpRoutes[svc]; len(backends) > 0 {
		primaryCluster = backends[0].Cluster
		break
	}
}

So for UDP:

  1. Backend weights are ignored entirely. common/l4project resolves and defaults weights (including weight: 0 as drain, fix(l4route): honor weight:0 as drain, don't normalize to 1 #492), and then the UDP path takes backends[0] and discards the rest. A UDPRoute with a 90/10 split silently sends 100% to one backend.
  2. Multiple UDPRoute-backed services on a node collapse onto one cluster. The loop takes the first non-empty service over the sorted key list and breaks. A second service's UDPRoute is accepted, projected, and then silently has no effect on that pod's listener.

The code says so itself — "This is the minimal viable control-plane shape" — and the sorted-key iteration is there for determinism (#135), not for correctness of the selection. Nothing tracks the gap.

Why it matters

The failure is silent on both sides: the UDPRoute is accepted by the API, the projector produces the right weighted backends, and the data plane quietly ignores them. There is no NACK, no warning, and no stat that distinguishes "weights applied" from "weights discarded" — so the first symptom is traffic in the wrong place.

It also means a UDPRoute e2e cannot assert backend selection, which is why this surfaced: #868 originally scoped a "UDPRoute picks the right backend" test, and that test would fail by design rather than find a bug.

Scope note

weight: 0-as-drain is meaningful for TCP and TLS and was a real shipped bug there (#492). For UDP it currently cannot be honoured at all.

Fix direction

Envoy's udp_proxy supports matcher-based route selection (and weighted clusters via the matcher API) in current versions; the comment's premise that it is unavailable predates the version now in use. Worth re-checking against the pinned Envoy before choosing between:

  • a matcher-based RouteSpecifier honouring weights and per-service selection; or
  • fail loudly — reject or warn on a UDPRoute whose weights cannot be honoured, and on the second UDPRoute-backed service per pod, so the silent case disappears even if full support waits.

The second is small and worth doing regardless: today the only way to discover this is to read the generator.

Acceptance

  • a UDPRoute with two weighted backends either splits per weight, or is rejected/warned with a stat — never silently single-homed
  • two UDPRoute-backed services on one node either both work, or the unsupported one is surfaced
  • whichever path is chosen, the assertion is seen red once before being trusted (aether#853)

Related: #868 (e2e coverage, which will document this as an explicit gap until fixed), #783 (shared L4 projector), #492 (weight: 0 drain for TCP).

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