Repository navigation
fix(llm-api-gateway): stop 502s leaking router errors under load - #2270
Conversation
Proxied request bodies were wrapped in io.NopCloser, so Go sent them chunked. When the router answers before reading a chunked body (for example its overload 503), it then closes the connection without Connection: close. The gateway reused the dead connection and the next POST failed with broken pipe or "server closed idle connection". - Set the outbound ContentLength from the Content-Length header the handlers already compute, so bodies go out with a fixed length. - Return a fixed 502 message for upstream transport errors and keep the original error as the internal error, which the request log records. Signed-off-by: along <along@nvidia.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review. 📝 WalkthroughWalkthroughThe gateway now forwards buffered requests with a fixed content length. For non-Echo errors, it returns a generic message and attaches the original error internally. Tests cover request framing and error handling. ChangesGateway upstream handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The test-comment updates do not change gateway behavior, and no actionable merge risk was identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
…outer-content-length Signed-off-by: along <along@nvidia.com>
The router fix sets the request length from the Content-Length header each handler computes. Cover that link end to end: for chat, responses and embeddings, the router must receive no chunked body and a Content-Length that matches the bytes it reads. Refs #2269 Signed-off-by: along <along@nvidia.com>
Refs: #2269 Signed-off-by: along <along@nvidia.com>
…outer-content-length
FamousDirector
left a comment
There was a problem hiding this comment.
No P0/P1 found. Both Proxy callers (proxy_handler.go, responses_handler.go) set Content-Length to the buffered body length, so the new fixed-length framing cannot mismatch; the internal transport error is still logged via the middleware's httpErr.Internal path. api and provider tests pass with -race on 2a49f69.
Non-blocking: providerHTTPError is also used by chat_handler, so non-transport provider messages (e.g. "stargate stream ended without chat completion chunks") are now returned as the generic message too; that seems fine but is a broader change than the title suggests. An explicit ContentLength field on ProxyRequest would be less implicit than parsing the header, if you touch this again.
ProxyRequest now carries ContentLength, so Proxy no longer parses the Content-Length header to choose fixed-length framing. Refs: #2269 Signed-off-by: along <along@nvidia.com>
|
@FamousDirector thanks for the review.
|
|
🎉 This PR is included in src/invocation-plane-services/llm-api-gateway/v0.14.9 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
|
This PR is included in version 1.29.4. The release is available on GitHub release. |
|
This PR is included in version 1.69.1. The release is available on GitHub release. |
|
This PR is included in version 1.25.1. The release is available on GitHub release. |
|
This PR is included in version 1.14.2. The release is available on GitHub release. |
|
This PR is included in version 1.10.1. The release is available on GitHub release. |
|
This PR is included in version 0.5.1. The release is available on GitHub release. |
|
This PR is included in version 0.9.1. The release is available on GitHub release. |
TL;DR
Under load, gateway 502s exposed the router's in-cluster URL, pod IPs and Go transport errors. Upstream transport errors now return a fixed 502 message, and proxied bodies go to the router with a fixed length instead of chunked.
Additional Details (optional for docs, build, test, refactor, ci, chore, style, and revert PRs)
For the Reviewer
provider/stargate.gotakes the length from theContent-Lengthheader. All current callers set it to the buffered body length.For QA (optional for docs, build, test, refactor, ci, chore, style, and revert PRs)
Content-Length. Both fail on main.Issues
Fixes #2269
Checklist