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

tonic-reflection: add back support for v1alpha reflection protocol #1888

Merged
merged 8 commits into from
Aug 23, 2024

Conversation

djc
Copy link
Collaborator

@djc djc commented Aug 23, 2024

Motivation

In tonic 0.12, we upgraded to v1 reflection. However, some tools (like Postman and Kreya) still use the v1alpha1 version of the reflection schema. This PR tries to add back the v1alpha reflection schema with minimal code duplication, by moving code around so that the Builder builds a schema-independent ReflectionServiceState which can be wrapped in a server following the requested schema version.

This should supersede #1787 and #1822 (thanks @ttkjesper for the input -- I've stolen your tests) while reducing code duplication.

Would be happy to get feedback on whether this works for people affected by this issue, as I'd like to get this merged into the pending 0.12.2 release.

Copy link
Collaborator

@tottoto tottoto 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 to me. Although the code become relatively complicated, it would be nice to support both versions until the ecosystem moves to v1.

tonic-reflection/src/server/mod.rs Show resolved Hide resolved
tonic-reflection/src/server/mod.rs Outdated Show resolved Hide resolved
@djc djc added this pull request to the merge queue Aug 23, 2024
Merged via the queue into master with commit 8d6d46b Aug 23, 2024
16 checks passed
@djc djc deleted the alpha-reflection branch August 23, 2024 19:48
tvlbot pushed a commit to tvlfyi/tvix that referenced this pull request Aug 27, 2024
tonic-reflection 0.12.x moved from the v1alpha to v1 of the reflection
protocol.

However, most clients, like Postman, Kreya and evans don't support that
one yet.

Bump tonic-reflection to 0.12.2, which re-introduces v1alpha support
alongside the v1 version of it, registering both services.

This fixes the example documented in tvix/store/README.md, it was
previously failing as evans couldn't find the v1alpha reflection
service.

See hyperium/tonic#1888 for details.

Change-Id: I55438877317f82dc39face13afeb9594cda07a4e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12353
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
@BButner
Copy link

BButner commented Aug 27, 2024

From a client perspective how should this properly be handled, differentiating between when to use v1 and v1alpha?

For instance: If I'm going to attempt to invoke a ServerReflectionRequest against a gRPC server that I do not know if its implemented v1 or v1alpha, what's the proper way of handling that? Should I attempt it first with using v1, and then if I get an Unimplemented error attempt to fallback on v1alpha?

@djc
Copy link
Collaborator Author

djc commented Aug 28, 2024

@BButner I don't have enough context on the nuances of gRPC versioning to answer this with any certainty. I suspect most clients will already know which version of the reflection their peer supports? If you (or anyone else) comes up with a good solution for this, kindly share it.

@BButner
Copy link

BButner commented Aug 28, 2024

@djc Yeah, that's a fair point. Specifically my use-case is with developing a tool to test gRPC servers, so being able to automatically tell which version they have is important. That does sound more like a me problem, and not a you/library problem.

Right now my plan is:

  1. Make the ServerReflectionRequest request with v1 first.
    a. If that succeeds, done!
    b. If it fails with Unimplemented as the error, proceed to 2.
  2. Make the ServerReflectionRequest with v1alpha.
    a. If that succeeds, done!
    b. If it fails, go to 3.
  3. Assume that the server just doesn't implement Server Reflection.

@djc
Copy link
Collaborator Author

djc commented Aug 28, 2024

Sounds about right to me.

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.

4 participants