mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #114] fix(proxy): probe upstream liveness with TCP keepalive #190
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#190
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/114
Author: @cleverhu
Created: 8/3/2026
Status: 🔄 Open
Base:
main← Head:fix/proxy-tcp-keepalive📝 Commits (2)
5b7d1ddperf(net): disable Nagle on the API server, proxy and envd clients7d784f2fix(proxy): probe upstream liveness with TCP keepalive📊 Changes
3 files changed (+32 additions, -3 deletions)
View changed files
📝
src/api/proxy.rs(+13 -0)📝
src/bin/server.rs(+9 -1)📝
thirdparty/envd/src/transport.rs(+10 -2)📄 Description
What
Enable TCP keepalive probes on the sandbox proxy's connector: 3 s idle before the first probe, 1 s between probes, 2 retries.
Why
Tearing down a VM never delivers FIN or RST to the host side of a proxied connection. The socket stays open from the host's point of view, so a request addressed to a sandbox that is already gone hangs until some higher-level timeout fires instead of failing immediately.
Keepalive probes are what detect that silence. With the values above the failure surfaces in roughly 5 s, which is a prompt error for a caller and still far above any plausible pause in normal proxied traffic.
Related issue
None. Small, self-contained reliability fix on an existing code path.
Scope and non-goals
Included: keepalive parameters on the proxy connector.
Excluded:
pool_max_idle_per_host(0)already handles the separate problem of interaction IPs being reused across runtime generations.Design and behavior changes
Three constants next to the existing
PROXY_CONNECT_TIMEOUT, applied viaHttpConnector::set_keepalive{,_interval,_retries}.Failure mode change: a request to a torn-down sandbox now returns a connection error after ~5 s instead of hanging. Callers that previously relied on a longer timeout to mask this will see the error sooner, which is the intent.
Compatibility and operations
[orchestrator]or a proxy section.TCP_KEEPIDLE/TCP_KEEPINTVL/TCP_KEEPCNTare Linux socket options and AgentENV is Linux-only.Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetCommands and results:
Skipped checks and reasons:
make test-unitnot run. Observing this behavior in a test requires a peer that vanishes without sending FIN/RST, which is not reproducible with an in-process test server; it needs a real VM teardown or an injected netfilter drop.Risks and reviewer notes
The risk worth reviewing is the aggressiveness of the values. A 3 s idle threshold with 1 s probes means an idle-but-alive sandbox connection sends a probe every second. That is negligible traffic on a host-local link, but if the proxy is ever used across a slower network the numbers deserve revisiting.
The other question is whether ~5 s to detect is the right target. It is well under typical client timeouts while leaving room for a transient stall.
Most important file:
src/api/proxy.rs.Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.