- Notifications
You must be signed in to change notification settings - Fork95
feat: Bidi uses metadata from start_rpc#205
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Allow Bidi to use metadata from start_rpc when no other metadatais provided.
No region tags are edited in this PR.This comment is generated bysnippet-bot.
|
| call=self._start_rpc(iter(request_generator),metadata=self._rpc_metadata) | ||
| # use metadata from self._start_rpc if no other metadata is specified | ||
| else: | ||
| call=self._start_rpc(iter(request_generator)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
When I set up BidiRPC withLoggingV2Transport().tail_log_entries, that's the unwrapped method, not the wrapped method. Will this still get the metadata from the wrapped method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
also, I tried passing in LoggingServiceV2Client().tail_log_entries and it didn't seem to work.
I'm actually not sure how pubsub passes in the wrapped method successfully.
https://github.com/googleapis/python-pubsub/blob/e907f6e05f59f64a3b08df3304e92ec960997be6/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L524
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
When I set up BidiRPC with LoggingV2Transport().tail_log_entries, that's the unwrapped method, not the wrapped method. Will this still get the metadata from the wrapped method?
I believe the wrapped one has to be passed in (the wrapper adds the metadata to the call)
also, I tried passing in LoggingServiceV2Client().tail_log_entries and it didn't seem to work.
I'm actually not sure how pubsub passes in the wrapped method successfully.
Hmm I'll go back and poke at what is actually expected to be passed in to Bidi.
tseaver left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Overall, LGTM. I'll let@plamut comment on possible Pub/sub interactions.
busunkim96 commentedJun 14, 2021
Looking at Firestore vs. Pub/Sub, I see Firestore is passing the method in thegRPC transport and Pub/Sub is passing the method in theGAPIC client. I wonder if that contributed to the behavior difference between the two that requiresthis workaround? (Also see:googleapis/python-pubsub#93 (comment) and#30) @jameslynnwu For it "not working" when |
jameslynnwu commentedJun 14, 2021
Great find! However, if I use the same workaround, it works. |
plamut commentedJun 16, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The Pub/Sub client passes the The subscriber client does not pass any metadata on its own to As for the changes in this PR - since no metadata is passed to Before the PR, call=self._start_rpc(iter(request_generator),metadata=self._rpc_metadata) With the changes in this PR, however, that changes: ifself._rpc_metadata:call=self._start_rpc(iter(request_generator),metadata=self._rpc_metadata)# use metadata from self._start_rpc if no other metadata is specifiedelse:call=self._start_rpc(iter(request_generator)) Since metadata is call=self._start_rpc(iter(request_generator)) No explicit When the (wrapped) method is eventually called, thefollowing logic in ifself._metadataisnotNone:metadata=kwargs.get("metadata", [])# Due to the nature of invocation, None should be treated the same# as not specified.ifmetadataisNone:metadata= []metadata=list(metadata) ... If I traced this correctly, there should be no difference between passing Does this answer the question? As for passing in a wrapped vs. un-wrapepd method - the regression caused by a Firestore fix back then seems to only affect the wrapped methods, yes, as the key changelives in in the We had to introduce a flag that changes how |
jameslynnwu commentedJun 16, 2021
One more thing to note, though we probably not want to address all of this at once. Passing in the If we can ensure that only Also, it's interesting that |
busunkim96 commentedJun 16, 2021
@plamut Thank you for the detailed analysis. 🙏 I'm OOO the rest of the week so I'll come back and look at this next week. |
busunkim96 commentedJun 25, 2021
As@plamut explained above, this PR is a no-op, if you pass the wrapped method the metadata will get added (which is why Pub/Sub doesn't pass I had a bit of trouble tracing this through but was able to confirm the expected headers in the gRPC logs: |
Uh oh!
There was an error while loading.Please reload this page.
Allow Bidi to use metadata from start_rpc when no other metadata
is provided.
This allows
client_infoon wrapped client methods will be passed through toBidiRpc.Fixes#202 🦕
Not expected to impact Firestore, as metadata is explicitly passed:https://github.com/googleapis/python-firestore/blob/e57258c51e4b4aa664cc927454056412756fc7ac/google/cloud/firestore_v1/watch.py#L220-L226
Pub/Sub does not seem to pass
metadataand may be impacted:https://github.com/googleapis/python-pubsub/blob/e907f6e05f59f64a3b08df3304e92ec960997be6/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L523-L528