Skip to content

route config: Allow to configure direct response body size#14778

Merged
htuch merged 17 commits intoenvoyproxy:mainfrom
dio:dr-route-config
Feb 2, 2021
Merged

route config: Allow to configure direct response body size#14778
htuch merged 17 commits intoenvoyproxy:mainfrom
dio:dr-route-config

Conversation

@dio
Copy link
Copy Markdown
Member

@dio dio commented Jan 21, 2021

Commit Message: This patch adds max_direct_response_body_size_bytes to set the maximum bytes of the direct response body size (in bytes). The config is added as a field in RouteConfiguration.

Additional Description: Reviving #13487 with a slightly different approach (add the config to RouteConfiguration instead of directly per direct response config entry).

Risk Level: Low, since the default behavior is preserved.
Testing: Updated to test the newly introduced config.
Docs Changes: Updated.
Release Notes: Added.
Fixes #13422

Signed-off-by: Dhi Aurrahman dio@rockybars.com

dio added 2 commits January 21, 2021 05:50
This patch allows configuring direct response body size, by setting
route config max_direct_response_body_size_bytes.

Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
API shepherd assignee is @mattklein123
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #14778 was opened by dio.

see: more, trace.

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @dio! I'll take this review since @mattklein123 is out.
/wait

// .. warning::
//
// The content of :ref:`direct response body
// <envoy_api_field_config.route.v3.DirectResponseAction.body>` will be held in memory.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you be more specific here? I.e. is the concern it's held in configuration memory, or in buffers on the response path, etc.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Tried to add more description on this. Please let me know if I put it wrongly.

@htuch htuch assigned htuch and unassigned mattklein123 Jan 22, 2021
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo comment in route.proto. Thanks!
/wait

// <envoy_api_field_config.route.v3.DirectResponseAction.body>` will be held in memory.
// Envoy currently holds the content of :ref:`direct response body
// <envoy_api_field_config.route.v3.DirectResponseAction.body>` in memory. Be careful setting
// this to be larger than the default 4KB. The default is limited to 4KB to keep the proxy's
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this the only reason? My understanding is we also want to avoid flooding watermarked buffers. E.g. if the buffer limits are 128KB and we dump 10MB in a direct response, that will be queued. @alyssawilk for thoughts.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, this is a gem. Thanks, @htuch! I didn't know that. I will do more digging. And, yes, I'll be very thankful if @alyssawilk can give some thoughts on this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think it'd be queued, I think we'd disable reading from a nonexistent upstream (and risk OOMs if there were lots of direct responses)
I think it'd be fine to allow larger responses (though I'd be inclined to add a warning note in the API about it not being subject to memory guards so use with care) but suggest an integration test to make sure it all works as I think it should :-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have added "standard" cases to the direct response integration test. If you think we need to cover more cases, please let me know. re: Buffer limit, I have a test case that sends 1000 * 4K so I think it's enough.

Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
dio added 6 commits January 26, 2021 02:17
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, but defer to @alyssawilk for a pass/merge.

// Envoy currently holds the content of :ref:`direct response body
// <envoy_api_field_config.route.v3.DirectResponseAction.body>` in memory. Be careful setting
// this to be larger than the default 4KB, since the allocated memory for direct response body
// is not being subject to memory guards.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I might phrase this as "data plane buffering controls" rather than "memory guards".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated.

Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
@dio
Copy link
Copy Markdown
Member Author

dio commented Jan 27, 2021

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #14778 (comment) was created by @dio.

see: more, trace.

@alyssawilk alyssawilk self-assigned this Jan 27, 2021
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Looks good overall - I'm sure this will be really useful to a lot of users - thanks for adding it!


TEST_P(DirectResponseIntegrationTest, DirectResponseBodySizeLarge) {
// Test with a large direct response body size.
testDirectResponseBodySize(1000 * 4096);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mind also setting
config_helper_.setBufferLimits(1024, 1024);
for this one?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated.

Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
alyssawilk
alyssawilk previously approved these changes Jan 28, 2021
* http: change frame flood and abuse checks to the upstream HTTP/2 codec to ON by default. It can be disabled by setting the `envoy.reloadable_features.upstream_http2_flood_checks` runtime key to false.
* overload: add support for scaling :ref:`transport connection timeouts<envoy_v3_api_enum_value_config.overload.v3.ScaleTimersOverloadActionConfig.TimerType.TRANSPORT_SOCKET_CONNECT>`. This can be used to reduce the TLS handshake timeout in response to overload.
* route config: added :ref:`max_direct_response_body_size_bytes <envoy_v3_api_field_config.route.v3.RouteConfiguration.max_direct_response_body_size_bytes>` to set maximum :ref:`direct response body <envoy_v3_api_field_config.route.v3.DirectResponseAction.body>` size in bytes. If not specified the default remains 4096 bytes.
* server: added :ref:`fips_mode <statistics>` statistic.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this a bad merge?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, sorry. This is updated.

dio added 2 commits February 1, 2021 21:36
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
@dio dio requested a review from htuch February 1, 2021 21:39
Copy link
Copy Markdown
Member

@htuch htuch 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!

@repokitteh-read-only repokitteh-read-only bot removed the api label Feb 2, 2021
@htuch htuch merged commit eeb7adc into envoyproxy:main Feb 2, 2021
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.

Give the option to increase the maximun size of the HTTP body in responses to be bigger than 4 KB

4 participants