Skip to content

feat: Implement requestBuffer #5661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2025
Merged

Conversation

markwinter
Copy link
Contributor

@markwinter markwinter commented Apr 4, 2025

What this PR does / why we need it:

This implements the new requestBuffer API using the Envoy's Buffer and BufferPerRoute filters.
API PR: #5537

Which issue(s) this PR fixes:

Fixes #3706

Release Notes: Yes

Copy link

codecov bot commented Apr 4, 2025

Codecov Report

Attention: Patch coverage is 62.13592% with 39 lines in your changes missing coverage. Please review.

Project coverage is 65.34%. Comparing base (096cb8d) to head (f1f1283).
Report is 54 commits behind head on main.

Files with missing lines Patch % Lines
internal/xds/translator/request_buffer.go 61.90% 22 Missing and 10 partials ⚠️
internal/gatewayapi/backendtrafficpolicy.go 56.25% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5661      +/-   ##
==========================================
+ Coverage   65.19%   65.34%   +0.14%     
==========================================
  Files         214      220       +6     
  Lines       34321    35092     +771     
==========================================
+ Hits        22377    22932     +555     
- Misses      10591    10749     +158     
- Partials     1353     1411      +58     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@markwinter markwinter marked this pull request as ready for review April 4, 2025 17:42
@markwinter markwinter requested a review from a team as a code owner April 4, 2025 17:42
@markwinter markwinter force-pushed the feat/request-buffer branch from 63c5792 to 4f7ffef Compare April 4, 2025 17:44
@markwinter markwinter requested a review from zirain April 10, 2025 20:49
@zirain zirain force-pushed the feat/request-buffer branch from 6affbbe to d6add20 Compare April 11, 2025 01:45
@zhaohuabing
Copy link
Member

zhaohuabing commented Apr 11, 2025

@markwinter Thanks so much for working on this great feature — really appreciate the effort you’re putting in!

If the BTP has a Gateway as a target, then we will configure the Buffer filter on the Listener. If the BTP has a HTTPRoute as a target, then we will configure the BufferPerRoute filter for that particular route. The BufferPerRoute will take precedence - I've tested having both applied and the BufferPerRoute maxBytes won.

This behavior is different than other types of settings in the BackendTrafficPolicy, where the settings targeting Gateway apply to all xRoutes. This inconsistent behavior of BackendTrafficPolicy could confuse users. We also can't apply a default RequestBuffer for all the xRoutes under a Gateway.

Another small thing: when the Buffer filter is applied at the Gateway level, it’s configured on all Listeners. While this makes sense (since BackendTrafficPolicy doesn’t target Listeners directly), it might be a bit unexpected from a user perspective.

I prefer keeping the same "Override" behavior as the other settings, and adding a Shared field in the RequestBuffer, similar to what we have done with the shared global ratelimit. We'll need to implement a "merge" mechanism to allow two-level request buffer settings. This is tracked at #1934 .

Shared global rate limit:

// Shared determines whether the rate limit rules apply across all the policy targets.
// If set to true, the rule is treated as a common bucket and is shared across all policy targets (xRoutes).
// Default: false.
//
// +optional
// +notImplementedHide
// +kubebuilder:default=false
Shared *bool `json:"shared,omitempty"`

cc @envoyproxy/gateway-maintainers

@arkodg
Copy link
Contributor

arkodg commented Apr 11, 2025

hey @markwinter as @zhaohuabing suggested, can the implementation push all the intent to per Route, and we can enhance this in the future with a shared api field to be able to set common per gateway buffers ?

@markwinter
Copy link
Contributor Author

@arkodg @zhaohuabing Thanks for the feedback. On holiday for a week and will return to the PR afterwards 👍

@arkodg
Copy link
Contributor

arkodg commented Apr 22, 2025

hey @markwinter hope you had a good break, feature freeze for v1.4 is April 30th, curious if you youd be able to complete this by then or prefer moving this to v1.5 ?

@markwinter markwinter force-pushed the feat/request-buffer branch from d6add20 to d3ac72e Compare April 27, 2025 00:24
Signed-off-by: mark winter <[email protected]>
@markwinter markwinter force-pushed the feat/request-buffer branch from d3ac72e to 2797b88 Compare April 27, 2025 00:29
@markwinter
Copy link
Contributor Author

markwinter commented Apr 27, 2025

@arkodg @zhaohuabing Sorry for the little bit of delay in getting back.

I've updated the request buffer xds patching.

Now the patchHCM will add the Buffer filter but in a Disabled: true state if there exists a route with request buffering. This is required to make any request buffering work at all, as BufferPerRoutes filters on routes by themselves are not enough. Then in patchRoute it will add the BufferPerRoute filter using that route's settings (if any) which will enable Buffer for that route.

If the BTP target was a Gateway all routes get the BufferPerRoute filter applied, and if the BTP target was just a Route, it gets added for just that route.

I took inspiration from how BasicAuth filter works which also adds a HCM filter in Disabled state, but then overrides the per route config.

Signed-off-by: mark winter <[email protected]>
@markwinter
Copy link
Contributor Author

/retest

Copy link
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for adding this ! this will be part of v1.4 😅

@arkodg arkodg merged commit b15fb64 into envoyproxy:main Apr 29, 2025
36 of 38 checks passed
@markwinter markwinter deleted the feat/request-buffer branch April 29, 2025 09:01
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.

Request/Response Buffering API support
4 participants