Skip to content
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

ext_proc: Support trailer callbacks #16102

Merged
merged 8 commits into from
Apr 29, 2021
Merged

Conversation

gbrail
Copy link
Contributor

@gbrail gbrail commented Apr 21, 2021

Commit Message: Support adding and modifying request and response trailers
in the ext_proc filter.

Additional Description:

Existing trailers will be sent to the processing
server if the processing mode is set to enable them. If the
processing mode is set to sent trailers, but there are no trailers
present, then empty trailers will be sent to the server for
modification.

However, trailers may only be added in the end of the data callback
in Envoy, which may come in before a previous gRPC reply returns.
Filters that need to be able to consistently add trailers where none
existed should enable trailer processing in the Envoy filter
configuration instead of relying on being able to turn it on
dynamically.

Risk Level: Low. Trailers only enabled if a service called by the filter
is configured to ask for them.

Testing: New integration and unit tests added.

Docs Changes: API docs updated in .proto files.

Release Notes:

When the processing mode is changed to SEND
for request or response trailers, a corresponding message will be
sent to the server, which can respond with trailer mutations as desired.

In addition, if trailer processing is enabled in the filter
configuration, then trailer messages will be sent to the server
even if trailers are not present. This makes it possible for the server
to add trailers where none exist.

Finally, at the moment Envoy only implements trailers for the HTTP/2
protocol. Nothing will happen if trailer processing is enabled and
Envoy is using HTTP/1 until Envoy implements trailers for HTTP/1.

Signed-off-by: Gregory Brail gregbrail@google.com

Commit Message: Support adding and modifying request and response trailers
in the ext_proc filter.

Additional Description:

Existing trailers will be sent to the processing
server if the processing mode is set to enable them. If the
processing mode is set to sent trailers, but there are no trailers
present, then empty trailers will be sent to the server for
modification.

However, trailers may only be added in the end of the data callback
in Envoy, which may come in before a previous gRPC reply returns.
Filters that need to be able to consistently add trailers where none
existed should enable trailer processing in the Envoy filter
configuration instead of relying on being able to turn it on
dynamically.

Risk Level: Low. Trailers only enabled if a service called by the filter
is configured to ask for them.

Testing: New integration and unit tests added.

Docs Changes: API docs updated in .proto files.

Release Notes:

When the processing mode is changed to SEND
for request or response trailers, a corresponding message will be
sent to the server, which can respond with trailer mutations as desired.

In addition, if trailer processing is enabled in the filter
configuration, then trailer messages will be sent to the server
even if trailers are not present. This makes it possible for the server
to add trailers where none exist.

Finally, at the moment Envoy only implements trailers for the HTTP/2
protocol. Nothing will happen if trailer processing is enabled and
Envoy is using HTTP/1 until Envoy implements trailers for HTTP/1.

Signed-off-by: Gregory Brail <gregbrail@google.com>
@repokitteh-read-only
Copy link

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

🐱

Caused by: #16102 was opened by gbrail.

see: more, trace.

gbrail added 2 commits April 21, 2021 21:21
Signed-off-by: Gregory Brail <gregbrail@google.com>
Signed-off-by: Gregory Brail <gregbrail@google.com>
@gbrail gbrail marked this pull request as ready for review April 22, 2021 05:15
@gbrail gbrail requested a review from snowp as a code owner April 22, 2021 05:15
Copy link
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.

Exciting to see more of the implementation arriving :)
/wait

Simplify state handling with just a few booleans.

Signed-off-by: Gregory Brail <gregbrail@google.com>
Signed-off-by: Gregory Brail <gregbrail@google.com>
Http::FilterDataStatus Filter::onData(ProcessorState& state, Buffer::Instance& data,
bool end_stream) {
if (end_stream) {
state.setCompleteBodyDelivered(true);
Copy link
Member

Choose a reason for hiding this comment

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

Non-actionable comment but I'm interested in your take; how adversarial are we treating remote ext_proc servers as being? One use case that might be interesting for ext_proc is allowing service chaining where trust relationships between infrastructure providers and tenants imply a threat model that doesn't fully trust the ext_proc server. Any thoughts on what would be required to make this fully robust?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now the relationship is pretty trusting -- ext_proc servers can set most headers, and they can manipulate the body and trailers too. There is an "ignore errors" setting which makes Envoy more resilient to a server failure, but without it a flaky server can definitely cause errors in the proxy as well.

I think that if we don't trust servers, then the user should certainly set up ext_proc to ignore errors from servers, and we might want to consider a model in which a server is limited by the proxy as to what it is allowed to change in the headers, trailers, and body.

Copy link
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 one small comment.

source/extensions/filters/http/ext_proc/ext_proc.cc Outdated Show resolved Hide resolved
gbrail added 3 commits April 26, 2021 20:42
Signed-off-by: Gregory Brail <gregbrail@google.com>
Based on code review.

Signed-off-by: Gregory Brail <gregbrail@google.com>
Signed-off-by: Gregory Brail <gregbrail@google.com>
Copy link
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!

@htuch htuch merged commit 29eb170 into envoyproxy:main Apr 29, 2021
gokulnair pushed a commit to gokulnair/envoy that referenced this pull request May 6, 2021
Existing trailers will be sent to the processing
server if the processing mode is set to enable them. If the
processing mode is set to sent trailers, but there are no trailers
present, then empty trailers will be sent to the server for
modification.

However, trailers may only be added in the end of the data callback
in Envoy, which may come in before a previous gRPC reply returns.
Filters that need to be able to consistently add trailers where none
existed should enable trailer processing in the Envoy filter
configuration instead of relying on being able to turn it on
dynamically.

Risk Level: Low. Trailers only enabled if a service called by the filter
is configured to ask for them.

Testing: New integration and unit tests added.

Docs Changes: API docs updated in .proto files.

Release Notes:

When the processing mode is changed to SEND
for request or response trailers, a corresponding message will be
sent to the server, which can respond with trailer mutations as desired.

In addition, if trailer processing is enabled in the filter
configuration, then trailer messages will be sent to the server
even if trailers are not present. This makes it possible for the server
to add trailers where none exist.

Finally, at the moment Envoy only implements trailers for the HTTP/2
protocol. Nothing will happen if trailer processing is enabled and
Envoy is using HTTP/1 until Envoy implements trailers for HTTP/1.

Signed-off-by: Gregory Brail <gregbrail@google.com>
Signed-off-by: Gokul Nair <gnair@twitter.com>
gokulnair pushed a commit to gokulnair/envoy that referenced this pull request May 6, 2021
Existing trailers will be sent to the processing
server if the processing mode is set to enable them. If the
processing mode is set to sent trailers, but there are no trailers
present, then empty trailers will be sent to the server for
modification.

However, trailers may only be added in the end of the data callback
in Envoy, which may come in before a previous gRPC reply returns.
Filters that need to be able to consistently add trailers where none
existed should enable trailer processing in the Envoy filter
configuration instead of relying on being able to turn it on
dynamically.

Risk Level: Low. Trailers only enabled if a service called by the filter
is configured to ask for them.

Testing: New integration and unit tests added.

Docs Changes: API docs updated in .proto files.

Release Notes:

When the processing mode is changed to SEND
for request or response trailers, a corresponding message will be
sent to the server, which can respond with trailer mutations as desired.

In addition, if trailer processing is enabled in the filter
configuration, then trailer messages will be sent to the server
even if trailers are not present. This makes it possible for the server
to add trailers where none exist.

Finally, at the moment Envoy only implements trailers for the HTTP/2
protocol. Nothing will happen if trailer processing is enabled and
Envoy is using HTTP/1 until Envoy implements trailers for HTTP/1.

Signed-off-by: Gregory Brail <gregbrail@google.com>
Signed-off-by: Gokul Nair <gnair@twitter.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