envoyproxy / envoyproxy/gateway

mergeBackends: a Gateway-level BackendTrafficPolicy's cluster settings are applied to merged UDP/TCP clusters regardless of protocol

Open
#10,015 0 comments 0 reactions 1 assignee Claimed by @kkk777-7 View on GitHub
kind/bug
Dominant language
Go
Stars
3k
Forks
864
Avg merge
2d 2h
Merged PRs (30d)
140

Description

*Description*:
I found this when working in https://github.com/envoyproxy/gateway/pull/9896

When `mergeBackends` is enabled, a whole-Gateway `BackendTrafficPolicy` copies its entire cluster-scoped feature set onto every merged `BackendCluster`, without looking at the backend's protocol. UDP and TCP clusters therefore receive settings that are deliberately dropped on every other code path.

Without `mergeBackends`, the IR type `ir.UDPRoute` only has `LoadBalancer` and `DNS` fields, so `healthCheck`, `circuitBreaker`, `tcpKeepalive`, `proxyProtocol`, `http2` and `useClientProtocol` from a BackendTrafficPolicy can never reach a UDP cluster.
With `mergeBackends`, those settings land in CDS for the very cluster `udp_proxy` routes to — most importantly `healthCheck.active`, which makes Envoy run TCP/HTTP health checks against a UDP-only port and can mark every endpoint unhealthy.

Expected:
the settings a merged cluster receives should match what the same policy would produce for that protocol without `mergeBackends`. Turning on cluster deduplication should not change behaviour.

*Repro steps*:
1. `EnvoyProxy` with `spec.mergeBackends: {}` attached to the GatewayClass.
2. Gateway with a UDP listener + a UDPRoute with a single `backendRef` (so the backend merges).
3. A BackendTrafficPolicy targeting the **Gateway** (no `sectionName`):

```yaml
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: gateway-1
healthCheck:
active:
type: TCP
timeout: 1s
interval: 5s
unhealthyThreshold: 3
healthyThreshold: 1
tcp:
send: {type: Text, text: ping}
receive: {type: Text, text: pong}
circuitBreaker:
maxConnections: 1024
```

4. Inspect the generated cluster `service////udp`.

Observed: the cluster carries `health_checks`, `circuit_breakers`, and (with HTTP timeouts / `maxRequestsPerConnection` / `useClientProtocol`) `typed_extension_protocol_options` (`HttpProtocolOptions`) — on the cluster used by `udp_proxy`.

Expected: only load balancing and DNS, i.e. identical to the same setup without `mergeBackends`.

*Environment*:
- Envoy Gateway: reproducible on main; `mergeBackends` was added in v1.9.0 (disabled by default, experimental), so only opt-in users are affected.

*Logs*:
>Include the access logs and the Envoy logs.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.