Skip to content

http: add upstream-request watermark callbacks to HCM#46020

Merged
botengyao merged 3 commits into
envoyproxy:mainfrom
penguingao:upstream-watermark-callbacks
Jul 7, 2026
Merged

http: add upstream-request watermark callbacks to HCM#46020
botengyao merged 3 commits into
envoyproxy:mainfrom
penguingao:upstream-watermark-callbacks

Conversation

@penguingao

Copy link
Copy Markdown
Contributor

Commit Message:
Introduce UpstreamWatermarkCallbacks (envoy/http/codec.h) and the (add|remove)UpstreamWatermarkCallbacks subscription API on StreamDecoderFilterCallbacks (envoy/http/filter.h), implemented by the FilterManager and fanned out from the connection manager's onDecoderFilter{Above,Below}WriteBuffer{High,Low}Watermark hooks.

Useful when a filter uses injectDecodedDataToFilterChain and wants to avoid overrunning the upstream buffer. This is a spawn-off of #45899 as per review.

Also adds stub overrides in the async client and tcp_proxy StreamDecoder FilterCallbacks implementations, a mock, and connection-manager coverage.

This change is a spawn-off of #45899, which I used AI to generate. I have read and understand the code.

Additional Description:
Risk Level: Medium - new callbacks to HCM, but not yet used
Testing: unit tests
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

Introduce UpstreamWatermarkCallbacks (envoy/http/codec.h) and the
add/removeUpstreamWatermarkCallbacks subscription API on
StreamDecoderFilterCallbacks (envoy/http/filter.h), implemented by the
FilterManager and fanned out from the connection manager's
onDecoderFilter{Above,Below}WriteBuffer{High,Low}Watermark hooks.

The downstream codec read-disable only slows the original request source.
A filter that produces request data of its own (e.g. by replaying a
buffered body via injectDecodedDataToFilterChain) does not see that
back-pressure, so it needs to subscribe here to pause/resume in step with
the upstream. A mid-stream subscriber is brought up to the current
back-pressure state on registration.

Adds stub overrides in the async client and tcp_proxy StreamDecoder
FilterCallbacks implementations, a mock, and connection-manager coverage.

Signed-off-by: Peng Gao <pengg@google.com>
@penguingao

Copy link
Copy Markdown
Contributor Author

/assign @wbpcode @botengyao

@penguingao

Copy link
Copy Markdown
Contributor Author

/cc @yanjunxiang-google / @markdroth you'll likely need this for ext_proc flow control

Merge main changes.

Signed-off-by: Peng Gao <pengg@google.com>
@penguingao

penguingao commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

fixing pre-existing format in #46022

Merge format fix.

Signed-off-by: Peng Gao <pengg@google.com>
@penguingao

Copy link
Copy Markdown
Contributor Author

/retest

@agrawroh

agrawroh commented Jul 7, 2026

Copy link
Copy Markdown
Member

Nice!

@botengyao

Copy link
Copy Markdown
Member

/retest

@botengyao
botengyao merged commit eae383c into envoyproxy:main Jul 7, 2026
27 of 28 checks passed
@yanjunxiang-google

Copy link
Copy Markdown
Contributor

LGTM! Thanks for working on this!

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.

5 participants