Repository navigation
fix(xds): an h2 mesh request to a vanished endpoint fails 503 in <=~9 s instead of hanging to the 15 s route timeout, and is never replayed (#1104) - #1113
Merged
Conversation
… s instead of hanging to the 15 s route timeout, and is never replayed (#1104) The h2 service clusters (NewServiceCluster: GAMMA weighted split, waypointed and edge->mesh traffic) configured neither TCP keepalive nor an HTTP/2 PING, so a request delivered to an endpoint whose pod veth then vanished got no FIN or RST and waited for the route timeout (504 UT at 15 s). Every h2 mesh cluster now carries http2_protocol_options.connection_keepalive {interval 1s, jitter 15%, timeout 8s} (config.MeshHttp2ProtocolOptions), the same 8 s budget as the QUIC twins (#1087) for the same #1093 reason. The keepalive close resets the stream as ConnectionTermination, which the mesh retry policy does not retry. Clusters whose h2 peer is not an aether proxy (app hop, authz, xDS, collector, passthrough) keep plain h2 options. Also corrects the NewServiceCluster comment: close_connections_on_host_health_failure fires only on active-HC failure or outlier ejection, never on the EDS drain mark. Proof: //test/envoy_validate TestH2MeshClustersDetectADeadPeer (14 h2 mesh clusters across every fixture, red on main), unit tests pinning the constants and bound, and e2e/eastwest-quic-deadpeer.sh verify-h2 on kind (red: 504 at 15.00 s; green: 503 at 10.1-10.95 s from request start, cut at 2 s; no replay). Closes #1104 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1104
What was happening
This is the h2 version of #1087. The h2 mesh clusters configured neither TCP keepalive nor an HTTP/2 PING. Take a request that the destination proxy had already received (TCP-ACKed) when its pod's veth was deleted:
504 UT.Since QUIC became unconditional, h2 carries three kinds of traffic: the GAMMA weighted split (by design, #961), waypointed (cross-cluster) traffic, and the edge→mesh hop.
Which builders have the hole. All three paths go through
proxy.NewServiceCluster:cache/cluster.go);cache/mtls.goonly swaps in the edge transport socket);NewServiceClusterend to end.ew_ingress_*is a rawtcp_proxyforwarder. The source's end-to-end PING passes through it, so the source side covers it. When the source closes on keepalive timeout, the tunnel's downstream closes andtcp_proxytears down its upstream.edge_k8s_*is HTTP/1.1 cleartext to non-mesh Services, so a PING is not possible there. Its exposure is also different: a non-mesh app closes its own sockets when it exits, before the sandbox network is torn down. It is out of scope; see risks.The fix
config.MeshHttp2ProtocolOptions()isHttp2ProtocolOptions()plus:It is used only by
NewServiceCluster. The constantsMeshH2KeepaliveInterval,MeshH2KeepaliveTimeoutandMeshH2KeepaliveJitterPercentsit next toQUICTwinKeepaliveInterval/QUICTwinNetworkIdleTimeout, with the same "tighten once #1093 is fixed" note.Envoy semantics at the pin (
726d7ac,source/common/http/http2/codec_impl.cc):random % (jitter% × interval)(:1011-1027,onKeepaliveResponse:1058-1071).connection_idle_intervalis a different knob. It sends a PING ahead ofnewStreamon an idle connection (:2420-2431). It is not set here.sendKeepalive:1036-1056). Any received frame pushes it out (:1216-1217), so a peer that is busy streaming a response is never cut off.NoFlushandkeepalive_timeoutis incremented (:1073-1079).CodecClient) follows streams only (codec_client.ccenable/disableIdleTimer), so PINGs do not hold an idle connection open pastUpstreamIdleTimeout.Not on
Http2ProtocolOptions(). That function is also used for the app hop (NewAppClusterhttp2), authz, xDS and collector clusters. Their h2 peer is not an aether proxy, and a gRPC server answers a PING every second withGOAWAY too_many_pings. The unit test, the proxy test and envoy_validate all assert that those clusters carry no keepalive.No replay, GET or POST:
LocalCloseon a connected client.CodecClient::onEventresets every active stream withConnectionTermination(codec_client.cc:124-137).wouldRetryFromReset(retry_state_impl.cc:433-490) does not retry it under the mesh policy (connect-failure,refused-stream,reset-before-request,retriable-status-codes[503]):Local/RemoteConnectionFailureandConnectionTimeout;reset-before-requestneeds!upstream_request_started, which is set fromfirst_upstream_tx_byte_sent_(router.cc:1650-1653);reset/5xxis configured.outboundRetryPolicy.Why 8 s (#1093). This is the same budget as the twins, for the same reason.
event.c:2072before:2091), and the read disables the timer, which removes its stale activation (event.c:2796-2810).Comment fixes. The
NewServiceClustercomment now saysclose_connections_on_host_health_failurefires only on active-HC failure (none is configured here) or outlier ejection (cluster_manager_impl.cc:971-988). An EDS removal only drains the host's pools (removeHosts → drainConnPools,:1954-1957), and in-flight streams keep waiting. I also fixed the circuit-breaker comment's "pool-close at drain-mark" and the matching assertion message inTestServiceClusterDrainPoolClose.Evidence
//test/envoy_validateTestH2MeshClustersDetectADeadPeer.envoy --mode validateaccepts, soTestEnvoyValidatealso proves Envoy accepts the keepalive on every shape.config.Http2ProtocolOptions(), which hid this. They now take their protocol options fromproxy.NewServiceClusteritself (meshClusterProtocolOptions()).Seen red on main with the test files applied to main's production code: an assertion failure, not a compile error.
It is green on the branch.
Unit tests.
config.TestMeshHttp2ProtocolOptionsDetectADeadPeerpins the constants and the bound: ≤ 10 s, timeout ≥ 8 s, and equal toQUICTwinNetworkIdleTimeout. It also asserts that plainHttp2ProtocolOptionshas no PING.proxy.TestServiceClusterH2PingLivenesschecks that the default and per-portNewServiceClustercarry the keepalive, and thatNewAppCluster(h2) and the passthrough do not.kind, red then green (
e2e/eastwest-quic-deadpeer.sh verify-h2, clusteraether-1104).Setup:
Arms:
swap-agent.config_dumpshowsconnection_keepaliveasnullon red and{"interval":"1s","interval_jitter":{"value":15},"timeout":"8s"}on green, on all six gamma clusters (default,:18081,:8080).Source stats after green:
cluster.aether-test/gamma-a.http2.keepalive_timeout: 32andupstream_cx_destroy_local_with_active_rq: 13. Theupstream_rq_retrycount comes from connect-failure retries of new requests to the dead host; N shows that none of them was a replay.Note: the first red run reported A2 and N as expected, but its B2 assertion "≥ 20 requests rode h2" was too tight once requests stall behind the hang. It is now ≥ 10; twins must still be +0. Every later run passed.
Commands:
Checks run
bazel testfor//agent/internal/xds/...,//agent/internal/edge/...,//test/envoy_validate:alland//test/mtlspool:all(real Envoy overNewServiceCluster, 66 s): all pass.--config=raceon//agent/internal/xds/config:alland//agent/internal/xds/proxy:all: pass.make gazelle,make format, andbazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: clean.No chart change. Docs:
docs/runbook.mdhas a new #1104 section, and the #1087 section now points to it.Risks
edge_k8s_*cleartext HTTP/1.1 clusters are unchanged. Only TCP keepalive could cover them, and a non-mesh backend closes its own sockets on exit, so their exposure is a node partition rather than a pod roll. Not addressed here.ew_ingresstcp_proxy. A stall of that gateway's worker counts against the same 8 s budget.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr