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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

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

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

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.28070% with 43 lines in your changes missing coverage. Please review.

Project coverage is 65.25%. Comparing base (61474e3) to head (d6add20).

Files with missing lines Patch % Lines
internal/xds/translator/request_buffer.go 63.63% 22 Missing and 10 partials ⚠️
internal/gatewayapi/backendtrafficpolicy.go 52.17% 8 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5661      +/-   ##
==========================================
- Coverage   65.27%   65.25%   -0.02%     
==========================================
  Files         213      214       +1     
  Lines       34104    34217     +113     
==========================================
+ Hits        22262    22330      +68     
- Misses      10502    10533      +31     
- Partials     1340     1354      +14     

☔ 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
Signed-off-by: mark winter <[email protected]>
Signed-off-by: mark winter <[email protected]>
Signed-off-by: mark winter <[email protected]>
Signed-off-by: mark winter <[email protected]>
Signed-off-by: mark winter <[email protected]>
Signed-off-by: mark winter <[email protected]>
Signed-off-by: mark winter <[email protected]>
Signed-off-by: mark winter <[email protected]>
@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 👍

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