Skip to content

Add support for gRPC calls. #100

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 14 commits into from
May 4, 2021
Merged

Conversation

Shikugawa
Copy link
Contributor

On the next release of Envoy, we will utilize cluster-specific gRPC call. We introduce this feature on the Rust SDK side in this PR.

@Shikugawa Shikugawa requested a review from PiotrSikora as a code owner April 1, 2021 08:46
@Shikugawa Shikugawa force-pushed the grpc-support branch 4 times, most recently from 4b76db7 to d83447f Compare April 1, 2021 16:36
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.

Could you rebase this PR on top of current master? Also, please regenerate Bazel rules using cargo-raze version mentioned in the README.md, and add the example to BUILD file.

@Shikugawa Shikugawa force-pushed the grpc-support branch 2 times, most recently from afcd8ac to b978698 Compare April 2, 2021 12:08
Signed-off-by: Rei Shimizu <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
@Shikugawa Shikugawa changed the title add gRPC call dispatch support add gRPC callout support Apr 2, 2021
Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
@@ -132,7 +133,7 @@ jobs:
run: cargo doc --no-deps --target=wasm32-unknown-unknown

- name: Package (publish)
run: cargo publish --dry-run --target=wasm32-unknown-unknown
run: cargo publish --dry-run --target=wasm32-unknown-unknown --no-verify
Copy link
Contributor Author

@Shikugawa Shikugawa Apr 2, 2021

Choose a reason for hiding this comment

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

This change is because CI will generate example/grpc_call/helloworld.rs while publishing but the commit doesn't have this file and to resolve this mismatch. If we include this file in this codebase, we will face mismatch also while publishing because built file doesn't have licence but committed file has this one. licencer doesn't have `exclude' option to skip verify while validation on dir walk. so we must add licence to the file while committing. If we have this PR on licencer, we don't have this workaround.

@Shikugawa
Copy link
Contributor Author

@PiotrSikora friendly ping

@PiotrSikora
Copy link
Member

@Shikugawa having protobuf compiler as a build dependency for the library is quite unfortunate, and I don't this acceptable.

I see 3 options:

  1. Find a way to execute build.rs and the protobuf compiler only when building examples.
  2. Make grpc_call a standalone crate under examples and remove references to it from the main Cargo.toml.
  3. Remove grpc_call example.

Signed-off-by: Shikugawa <[email protected]>
@Shikugawa
Copy link
Contributor Author

@PiotrSikora For now we should delete grpc callout example.

Signed-off-by: Shikugawa <[email protected]>
@Shikugawa
Copy link
Contributor Author

@PiotrSikora Could we merge this?

@PiotrSikora
Copy link
Member

@PiotrSikora Could we merge this?

I'll get back to reviewing this in a day or two, sorry.

Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
message,
timeout,
)
}
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for missing it earlier, but you're missing grpc_cancel host call (it should probably be called cancel_grpc_call to match the existing naming convention).

Signed-off-by: Shikugawa <[email protected]>
src/hostcalls.rs Outdated
status => panic!("unexpected status: {}", status as u32),
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe grpc_close is used for gRPC call, it's effectively an alias for grpc_cancel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with it. But host provides a path to reset gRPC call so that we should provide it on SDK side, I think.

Copy link
Member

Choose a reason for hiding this comment

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

What I'm saying is that both grpc_cancel and grpc_close are doing exactly the same thing in Envoy for gRPC calls:

Context::grpcClose:
https://github.com/envoyproxy/envoy/blob/87d5eb7d44e4b24b2d098ce073f8742610c5d03e/source/extensions/common/wasm/context.cc#L1886-L1895

Context::grpcCancel:
https://github.com/envoyproxy/envoy/blob/87d5eb7d44e4b24b2d098ce073f8742610c5d03e/source/extensions/common/wasm/context.cc#L1913-L1922

It would be actually interesting to see what happens on the wire, i.e.is it RST_STREAM(CANCEL)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. so we should provide cancel_grpc_call on unary call, and cancel_grpc_stream which send RST_STREAM and close_grpc_stream which transit the caller state to Half-Closed, Right?

Copy link
Member

Choose a reason for hiding this comment

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

Right.

Signed-off-by: Shikugawa <[email protected]>
@PiotrSikora PiotrSikora changed the title add gRPC callout support Add support for gRPC calls. Apr 27, 2021
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'll run some end-to-end tests tomorrow before merging, but everything looks good.

Thanks and sorry for the nitpicking!

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.

There is no support for reading the gRPC response. Please add it.

@PiotrSikora
Copy link
Member

There is no support for reading the gRPC response. Please add it.

You only need to add get_grpc_call_response_body in src/traits.rs and GrpcCallResponseBody in src/types.rs.

Signed-off-by: shikugawa <[email protected]>
@Shikugawa
Copy link
Contributor Author

Shikugawa commented May 4, 2021

@PiotrSikora Sorry for my delay! I added get_grpc_call_response_body as well as get_grpc_call_initial/trailing_metadata.

@PiotrSikora
Copy link
Member

I added [...] get_grpc_call_initial/trailing_metadata.

Those are actually not available in unary gRPC calls. Compare Envoy interfaces for gRPC calls and gRPC streams.

@Shikugawa
Copy link
Contributor Author

@PiotrSikora After merged this, I will continue to work #101. So I don't think it should be a problem for users.

@PiotrSikora
Copy link
Member

@PiotrSikora After merged this, I will continue to work #101. So I don't think it should be a problem for users.

  1. They are not part of the "gRPC calls" feature, so they should not be part of this PR.
  2. They are named get_grpc_call_..., and not get_grpc_stream_....

If you want to include them in #101 that's great, but I think they should be removed from this PR.

Signed-off-by: shikugawa <[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.

LGTM, sans nit.

Signed-off-by: shikugawa <[email protected]>
@PiotrSikora PiotrSikora merged commit 30066a7 into proxy-wasm:master May 4, 2021
@PiotrSikora
Copy link
Member

Thanks!

@Shikugawa Shikugawa deleted the grpc-support branch May 4, 2021 11:48
@PiotrSikora PiotrSikora mentioned this pull request May 28, 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.

2 participants