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

Force stop iteration after local response is sent #88

Merged
merged 8 commits into from
Nov 9, 2020

Conversation

mathetake
Copy link
Contributor

@mathetake mathetake commented Nov 3, 2020

@mathetake
Copy link
Contributor Author

mathetake commented Nov 3, 2020

I made the change almost identical to envoyproxy/envoy#13873 but something weird seems to happen here:

with the change in Envoy, the decorder/encoder message like this and it looks fine (I mean, the local response is be sent to the client properly).

[2020-11-03 16:21:04.041][871494][trace][http] [source/common/http/filter_manager.cc:938] [C0][S552029742600055844] encode headers called: filter=0x3f33ffcd47d0 status=0
[2020-11-03 16:21:04.041][871494][trace][http] [source/common/http/filter_manager.cc:1080] [C0][S552029742600055844] encode data called: filter=0x3f33ffcd47d0 status=0
[2020-11-03 16:21:04.041][871494][trace][http] [source/common/http/filter_manager.cc:451] [C0][S552029742600055844] decode headers called: filter=0x3f33fea12540 status=1

but with the change here, we have the following logs, and the response never is never returned to the client (curl in this case)

[2020-11-03 16:26:52.872][887837][trace][http] [source/common/http/filter_manager.cc:938] [C0][S6785004984496335233] encode headers called: filter=0xe013e0a8370 status=1
[2020-11-03 16:26:52.872][887837][trace][http] [source/common/http/filter_manager.cc:1080] [C0][S6785004984496335233] encode data called: filter=0xe013e0a8370 status=3
[2020-11-03 16:26:52.872][887837][trace][http] [source/common/http/filter_manager.cc:451] [C0][S6785004984496335233] decode headers called: filter=0xe013ea07f20 status=1

It seems like the change here somehow affects the encoder of local reply (I'm not sure how local response is handled in Envoy) and stops it from continuing 🤔

src/exports.cc Outdated Show resolved Hide resolved
src/context.cc Outdated Show resolved Hide resolved
Signed-off-by: mathetake <[email protected]>
@mathetake mathetake changed the title stop iteration if local response sent add stop iteration flag for stop iteration on context Nov 3, 2020
@mathetake
Copy link
Contributor Author

same problem lingers on.......

@mathetake
Copy link
Contributor Author

mathetake commented Nov 3, 2020

it seems to me that OnResponseHeaders and OnResponseBody are called in response to the sendLocalResponse? And the BaseContext used to handle these events must be the same the context which invoked sendLocalResponse, which means stop_iteration_ is true for the local response as well. I think that is the difference and something unexpected seems happening

@mathetake
Copy link
Contributor Author

I'm know next to nothing about the internal behavior of local response, but the logs show that the filter addresses(?) are different

@PiotrSikora
Copy link
Member

it seems to me that OnResponseHeaders and OnResponseBody are called in response to the sendLocalResponse? And the BaseContext used to handle these events must be the same the context which invoked sendLocalResponse, which means stop_iteration_ is true for the local response as well. I think that is the difference and something unexpected seems happening

Yes, OnResponse{Headers,Body,Trailers} are called for the local response as well.

@mathetake mathetake marked this pull request as ready for review November 3, 2020 14:59
src/context.cc Show resolved Hide resolved
src/context.cc Show resolved Hide resolved
@mathetake mathetake requested a review from PiotrSikora November 4, 2020 02:07
Copy link
Member

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

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

This looks great, thanks! Although, I wonder if we should be so permissive and "fix" the broken code on the fly.

Similarly, could you open a PR in Envoy against your branch to verify that it passes all tests?

include/proxy-wasm/context.h Outdated Show resolved Hide resolved
@mathetake
Copy link
Contributor Author

Although, I wonder if we should be so permissive and "fix" the broken code on the fly.

Agreed

@mathetake
Copy link
Contributor Author

@PiotrSikora envoyproxy/envoy#13930 all tests passed!

@PiotrSikora PiotrSikora changed the title add stop iteration flag for stop iteration on context Force stop iteration after local response is sent Nov 9, 2020
@PiotrSikora PiotrSikora merged commit 376ffaf into proxy-wasm:master Nov 9, 2020
@PiotrSikora
Copy link
Member

@mathetake It looks that we don't have good coverage, since this breaks send local reply in production code.

@PiotrSikora
Copy link
Member

@mathetake OK, I see the issue now. We're overriding "current" action with StopAllIterationAndWatermark, however, not all callbacks return action (most notably, on_http_call_response does not), in which case we're not overriding "current" action, but action of the subsequent call. We need to clear stop_iteration_ flag after we return from VM, not when converting actions.

@mathetake mathetake deleted the local-reply-stop branch November 10, 2020 09:28
istio-testing pushed a commit to istio/envoy that referenced this pull request Nov 20, 2020
* build: update rules_rust to allow Rustc in RBE (envoyproxy#13595)

Signed-off-by: Lizan Zhou <[email protected]>
Signed-off-by: Piotr Sikora <[email protected]>

* fix macos v8 build (envoyproxy#13572)

Signed-off-by: Rama Chavali <[email protected]>

* wasm: update proxy-wasm-cpp-host (envoyproxy#13606)

The PR updates proxy-wasm-cpp-host dependency for enhancing the capability and fixing a bug in WASM extensions.

The change consists of three PRs in proxy-wasm-cpp-host:

1. proxy-wasm/proxy-wasm-cpp-host#68 @PiotrSikora
2. proxy-wasm/proxy-wasm-cpp-host#65 @mathetake (me)
3. proxy-wasm/proxy-wasm-cpp-host#64 @mathetake (me)

The code change can be found at proxy-wasm/proxy-wasm-cpp-host@49ed20e...c5658d3 .

1 & 2 enhance WASM capability, and 3 fixes a bug in situations where users share vm_id for multiple filters. For details, please take a look at these original PRs.

Signed-off-by: mathetake <[email protected]>
Signed-off-by: Piotr Sikora <[email protected]>

* wasm: re-enable tests with precompiled modules. (envoyproxy#13583)

Fixes envoyproxy#12335.

Signed-off-by: Piotr Sikora <[email protected]>

* wasm: flip the meaning of the "repository" in envoy_wasm_cc_binary(). (envoyproxy#13621)

Change the meaning of the "repository" parameter to refer to an external
Bazel repository, instead of using "@envoy" in targets that are included
in the Envoy repository.

This aligns with other envoy_* rules.

Signed-off-by: Piotr Sikora <[email protected]>

* build: support ppc64le with wasm (envoyproxy#13657)

The build has only been tested with gn git sha 5da62d5 as
recommended by ppc64 maintainers of the v8 runtime.

Signed-off-by: Christopher M. Luciano <[email protected]>

* wasm: remove no longer needed Emscripten metadata. (envoyproxy#13667)

Signed-off-by: Piotr Sikora <[email protected]>

* fix wasm compilation (envoyproxy#13765)

Signed-off-by: Asra Ali <[email protected]>

* wasm: strip only Custom Sections with precompiled Wasm modules. (envoyproxy#13775)

Signed-off-by: Piotr Sikora <[email protected]>

* build: don't build shared libraries for zlib and zlib-ng. (envoyproxy#13652)

Signed-off-by: Piotr Sikora <[email protected]>

* wasm: update V8 to v8.7.220.10. (envoyproxy#13568)

Signed-off-by: Piotr Sikora <[email protected]>

* build: exclude wee8/out from inputs (envoyproxy#13866)

If you build without sandboxing for performance, the output files from
this custom build genrule contained timestamps which caused it to
rebuild every single build.

Signed-off-by: Keith Smiley <[email protected]>

* tls: fix detection of the upstream connection close event. (envoyproxy#13858)

Fixes envoyproxy#13856.

Signed-off-by: Piotr Sikora <[email protected]>

* wasm: Force stop iteration after local response is sent (envoyproxy#13930)

Resolves envoyproxy#13857

ref:
-proxy-wasm/proxy-wasm-rust-sdk#44
-proxy-wasm/proxy-wasm-cpp-host#88
-proxy-wasm/proxy-wasm-cpp-host#93

Signed-off-by: mathetake <[email protected]>
Signed-off-by: Piotr Sikora <[email protected]>

* wasm: fix order of callbacks for paused requests. (envoyproxy#13840)

Fixes proxy-wasm/proxy-wasm-rust-sdk#43.

Signed-off-by: Piotr Sikora <[email protected]>

* wasm: fix network leak (envoyproxy#13836)

Signed-off-by: Kuat Yessenov <[email protected]>

Co-authored-by: Lizan Zhou <[email protected]>
Co-authored-by: Rama Chavali <[email protected]>
Co-authored-by: Takeshi Yoneda <[email protected]>
Co-authored-by: cmluciano <[email protected]>
Co-authored-by: asraa <[email protected]>
Co-authored-by: Keith Smiley <[email protected]>
Co-authored-by: Takeshi Yoneda <[email protected]>
Co-authored-by: Kuat <[email protected]>
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