Repository navigation
feat(relay): add opt-in HTTP/2 health checks - #8059
Perfecto23 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Configure relay PING timing .env.example, common/constants.go, common/init.go |
Adds settings for the idle interval and acknowledgement timeout. Environment loading defaults them to 0 and 15 seconds. The example file documents their scope and behavior. |
Apply and verify relay PING probes service/http_client.go, service/http_client_transport_test.go |
When the idle interval is positive, the transport configures HTTP/2 PING timing and clamps the values. Tests cover disabled probes, acknowledged probes, and unanswered probes that cause a lost connection. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant RelayClient
participant RelayHTTPTransport
participant HTTP2Peer
RelayClient->>RelayHTTPTransport: Send request
RelayHTTPTransport->>HTTP2Peer: Send PING after idle interval
HTTP2Peer-->>RelayHTTPTransport: Acknowledge PING
RelayHTTPTransport-->>RelayClient: Continue response on connection
HTTP2Peer--xRelayHTTPTransport: Withhold PING acknowledgement
RelayHTTPTransport-->>RelayClient: Report lost connection
Possibly related issues
- feat: 配置 HTTP/2 PING 保活机制,防止空闲连接被中间设备 RST #5308: The issue requests HTTP/2 PING keepalive settings for relay connections. This change adds settings with the same names and purpose, but defaults the idle interval to 0 rather than the proposed 30 seconds.
Suggested reviewers: calcium-ion
Merge Risk: 
Minimal · up to cedb0
-
The opt-in checks appear to reach the supported relay modes, with no actionable issue identified before merge.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "feat(relay): add opt-in HTTP/2 health checks" names the main change. The PR adds opt-in HTTP/2 PING health checks for relay upstream connections, controlled by RELAY_HTTP2_PING_IDLE_TIMEOUT (default 0, disabled) and RELAY_HTTP2_PING_TIMEOUT (default 15). The title is short, specific, and matches the objectives and the changed files in common/, service/http_client.go, and the transport tests.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 4 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the silent stream,
A PING goes out to test the beam.
If answered, slow replies can stay,
If not, the link gives way.
Fresh paths await the next request,
And carrots crown the health-check quest.
Comment @coderabbitai help to get the list of available commands.
Agent
Links
User request
基于实际遇到的 Azure 长请求超时与断流问题,完善 New API 的上游连接健康探测和故障恢复。复用现有传输层机制,保持正常慢响应、代理和连接分片的兼容性,并通过可复现的修改前后对照验证效果。
公开说明故障现象、已确认的原因及仍待验证的部分,提交范围聚焦、便于维护者审查的上游改动。
Out of scope — refuse
Open gate — do not open unless all are satisfied
go buildor tests passed: yes。Kind
Issue facts
connection reset by peer/ HTTP 500。newRelayHTTPTransport()启用 HTTP/2,但未配置连接健康探测;本地真实 HTTP/2 对端停止应答 PING 时可复现等待客户端超时。Change
新增两个启动环境变量,通过 Go 标准库
http.HTTP2Config配置共享 Transport:RELAY_HTTP2_PING_IDLE_TIMEOUT=0默认保持现有行为,正数启用探测;RELAY_HTTP2_PING_TIMEOUT=15控制等待应答的时间。超大值在转成time.Duration前截断,PING 超时非正数使用 Go 默认值。实际使用中,我们在 rc.44 的官方 Azure 渠道遇到过间歇性 408/5xx,以及发出 SSE 心跳后错误被客户端读成空流的情况。升级 rc.47 后,用 OpenAI Python SDK 2.48.0 验证了 #7857 的错误交付修复。本 PR 补充连接健康探测;现场 Azure 408 与失效 HTTP/2 连接之间的因果关系仍待验证。
Research
Duplicate / prior art
HTTP2、PING、keepalive、transport、Azure timeout,覆盖 open / closed issues 和 PRs。IdleConnTimeout;fix(relay): set Request.GetBody so the HTTP/2 transport can transparently retry after an upstream stream reset #6249 已处理可安全重试的 HTTP/2 reset。本 PR 沿用共享工厂,为已有需求补上可选探测,无新增重试循环。Docs and code
README.md的贡献要求、AGENTS.md、.env.example;按.agents/github/PR.md填写本说明。common.InitEnv→newRelayHTTPTransport→ 直连 / 代理 / 分片客户端;Go HTTP2Config 区分连接探测与整次请求超时。Alternatives considered
IdleConnTimeout各自保留原职责。Files
common/constants.go,common/init.goservice/http_client.go.env.exampleservice/http_client_transport_test.goBehavior
Verification
go test ./service -run '^TestRelayHTTP2HealthCheck$' -count=1 -v:关闭探测时等待客户端超时且无 PING;正常对端应答两次 PING 后返回完整响应;失效对端触发http2: client connection lost,下一请求通过新连接完成。go test -overlay仅将service/http_client.go替换为 base 版本再运行同一测试:开启探测的两个用例均等待到客户端超时,关闭探测用例通过。go test -race ./service -run 'TestRelayHTTP2HealthCheck|TestAutoOneShard|TestFourShard|TestForcedHTTP1|Test.*Proxy|TestCloseIdleConnections' -count=1:通过;HTTP/1.1、代理、分片和缓存重建行为保持。go test ./service -count=1、根模块GOWORK=off go vet ./.../go build ./...、分别在relaykit/和tokenkit/运行GOWORK=off go test ./...:通过。根构建按 CI 建立忽略的前端 embed 占位文件。make test:根模块仅advancedcustom/TestAdaptorMasksDialedHostsInDialFailure/channel_proxy_host失败;在未修改的 base34003e9c2单独运行同一用例得到相同失败:预期代理域名,实际unexpected EOF。两个独立模块已分别补跑通过。start,后续新请求得到startend。Risks
Scope check
Summary by CodeRabbit
RELAY_HTTP2_PING_IDLE_TIMEOUTandRELAY_HTTP2_PING_TIMEOUT.