Skip to content

Refactor around VM failure check on Http/Tcp callbacks. #155

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 7 commits into from
Apr 28, 2021

Conversation

mathetake
Copy link
Contributor

@mathetake mathetake commented Apr 20, 2021

Relevant to envoyproxy/envoy#14947.
Refactored around VM failure check on Http and Tcp callbacks in order to handle the VM failure right after it happens. Previously, for example, when panic happens in OnResponseHeaders, then we return Continue since we didn't check the isFail after the Wasm calls. That means Envoy sends the response headers to the client even if the VM fails in OnResponseHeaders, and the failClose is called on OnResponseBody. This seems problematic and unintended.

This is WIP since I haven't passed Envoy tests.

Signed-off-by: Takeshi Yoneda [email protected]

Signed-off-by: Takeshi Yoneda <[email protected]>
@mathetake mathetake changed the title Add POSTCHECK on Http/Tcp callbacks. Refactor around VM failure check on Http/Tcp callbacks. Apr 21, 2021
@mathetake mathetake marked this pull request as ready for review April 21, 2021 03:17
@mathetake mathetake requested a review from PiotrSikora as a code owner April 21, 2021 03:17
@mathetake
Copy link
Contributor Author

OK now envoy test passes.

Signed-off-by: Takeshi Yoneda <[email protected]>
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.

Thanks! Could you make sure that

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.

I'm wondering if those pre-checks are even necessary? We catch all initialization failures in configuration phase, and all runtime failures should be caught by those new post-checks.

Am I missing something?

In any case, this is definitely an improvement, so feel free to merge as-is once Envoy tests pass.

@mathetake
Copy link
Contributor Author

Good point. For other stream contexts than the context where VM traps, the processing normally proceeds even after the VM failure. That's why we must have prechecks as well..?

@PiotrSikora
Copy link
Member

Oh yeah, good point.

@mathetake mathetake merged commit 5791899 into proxy-wasm:master Apr 28, 2021
@mathetake mathetake deleted the precheck-callback branch April 28, 2021 00:29
lizan pushed a commit to envoyproxy/envoy that referenced this pull request May 4, 2021
Fixes #14947 and properly closes streams. This commit differentiates `failStream` from `closeStream` where the former is called when a VM fails, and the latter is called via `close_stream` or `grpc_close` by user Wasm codes. Notably, we try to send local response with 503 for http streams as expected by the description of `fail_open` api.
The change here is a little and mostly done in Proxy-Wasm C++ host implementation(proxy-wasm/proxy-wasm-cpp-host#155).

Signed-off-by: Takeshi Yoneda <[email protected]>
gokulnair pushed a commit to gokulnair/envoy that referenced this pull request May 6, 2021
Fixes envoyproxy#14947 and properly closes streams. This commit differentiates `failStream` from `closeStream` where the former is called when a VM fails, and the latter is called via `close_stream` or `grpc_close` by user Wasm codes. Notably, we try to send local response with 503 for http streams as expected by the description of `fail_open` api.
The change here is a little and mostly done in Proxy-Wasm C++ host implementation(proxy-wasm/proxy-wasm-cpp-host#155).

Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Gokul Nair <[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