Skip to content

refactor: stop sending request bodies twice to extproc#636

Merged
mathetake merged 4 commits intomainfrom
lightweight
May 23, 2025
Merged

refactor: stop sending request bodies twice to extproc#636
mathetake merged 4 commits intomainfrom
lightweight

Conversation

@mathetake
Copy link
Copy Markdown
Member

@mathetake mathetake commented May 23, 2025

Commit Message

Previously, request body phase was unnecessarily called for upstream filter extproc, hence the entire request body was traveling from Envoy to the extproc at least twice (+ retry). This does the small refactoring of the extproc code so that it will utilize CONTINUE_AND_REPLACE status on the request headers phase since it can access the original body saved in memory at the routing phase. This helps the memory pressure reduction.

Related Issues/PRs (if applicable)

mathetake added 3 commits May 23, 2025 09:26
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake mathetake marked this pull request as ready for review May 23, 2025 16:37
@mathetake mathetake requested a review from a team as a code owner May 23, 2025 16:37
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake mathetake merged commit 65ca02a into main May 23, 2025
17 checks passed
@mathetake mathetake deleted the lightweight branch May 23, 2025 16:54
mathetake added a commit that referenced this pull request Jun 10, 2025
**Commit Message**

Previously, AWS signing has included the "content-length" header.
However, Envoy's extproc filter strips it from the request as we are
using CONTINUE_AND_REPLACE option to reduce the memory overhead. While
we have still no clue as to why AWS doesn't complain when the request
body is small, excluding content-length from the signing target headers
will make the tests with both small and large bodies pass.

**Related Issues/PRs (if applicable)**

CONTINUE_AND_REPLACE was introduced in #636 to avoid sending a request
body twice between Envoy and the ExtProc.

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
yuzisun pushed a commit to yuzisun/ai-gateway that referenced this pull request Jun 10, 2025
**Commit Message**

Previously, AWS signing has included the "content-length" header.
However, Envoy's extproc filter strips it from the request as we are
using CONTINUE_AND_REPLACE option to reduce the memory overhead. While
we have still no clue as to why AWS doesn't complain when the request
body is small, excluding content-length from the signing target headers
will make the tests with both small and large bodies pass.

**Related Issues/PRs (if applicable)**

CONTINUE_AND_REPLACE was introduced in envoyproxy#636 to avoid sending a request
body twice between Envoy and the ExtProc.

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
yuzisun added a commit that referenced this pull request Jun 10, 2025
**Commit Message**

Previously, AWS signing has included the "content-length" header.
However, Envoy's extproc filter strips it from the request as we are
using CONTINUE_AND_REPLACE option to reduce the memory overhead. While
we have still no clue as to why AWS doesn't complain when the request
body is small, excluding content-length from the signing target headers
will make the tests with both small and large bodies pass.

**Related Issues/PRs (if applicable)**

CONTINUE_AND_REPLACE was introduced in #636 to avoid sending a request
body twice between Envoy and the ExtProc.

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
mathetake added a commit that referenced this pull request Jun 27, 2025
**Description**

This reverts 65ca02a. It was introduced
to avoid sending request bodies twice to the extrpoc. However, the
current implementation of extproc in Envoy side will ALWAYS remove
content-length header hence result in forcing the chunked
transfer-encoding. That causes some issue with some AI providers as
described in #721 for example.

**Related Issues/PRs (if applicable)**

Reverts #636
Fixes #721

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants