xDS: Support retries in RawMessageClientInterceptor and conditionally add it to the filter chain - #13042
Open
kannanjgithub wants to merge 2 commits into
Open
xDS: Support retries in RawMessageClientInterceptor and conditionally add it to the filter chain#13042kannanjgithub wants to merge 2 commits into
kannanjgithub wants to merge 2 commits into
Conversation
…payload access Introduce Filter.requiresPayloadAccess(config, overrideConfig) to allow filters to declare whether they need access to message payloads. Update ExternalProcessorFilter to implement this method, returning false when body send mode is NONE for both request and response. Update XdsNameResolver to only install RawMessageClientInterceptor when at least one configured filter requires payload access. Generalize ExternalProcessorClientInterceptor to support generic request/response types when payload interception is not needed. TAG=agy CONV=56c87717-243d-4f12-af9e-c532e509892a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Supporting retries
Previously,
RawMessageClientInterceptor.sendMessage()forwarded a single-useInputStream directly to
rawCall.sendMessage(). When retries were triggered byRetriableStream, attempt 1 drained the InputStream to EOF. Subsequent retry
attempts would then serialize the already-drained stream, sending an empty (0-byte)
request payload.
Fix this by:
ByteString(usingDrainablewhen supported) in
RawMessageClientInterceptor.sendMessage()and wrapping itin a
KnownLengthInputStream.getByteString()onKnownLengthInputStream.RAW_MARSHALLER.stream()return a freshKnownLengthInputStreamwrappingthe underlying
ByteStringon each attempt, allowing retries to read the payloadfrom byte 0.
2. Conditional addition of
RawMessageClientInterceptorAlso we need to only install
RawMessageClientInterceptorwhen a filter requires payload access to avoid the performance hit for non ext_proc cases. As suggested in the grfc discussion, introduceFilter.requiresPayloadAccess(config, overrideConfig)to allow filters to declare whether they need access to message payloads. UpdateExternalProcessorFilterto implement this method, returning false when body send mode is NONE for both request and response. UpdateXdsNameResolverto only installRawMessageClientInterceptorwhen at least one configured filter requires payload access. GeneralizeExternalProcessorClientInterceptorto support generic request/response types when payload interception is not needed.Generalizing
ExternalProcessorClientInterceptorto Support Pass-through TypesExternalProcessorClientInterceptorpreviously hardcodedClientCall<InputStream, InputStream>andSimpleForwardingClientCallListener<InputStream>, assumingRawMessageClientInterceptorwas always present earlier in the chain to convert application messages toInputStream.Now that
RawMessageClientInterceptoris omitted when body send mode isNONE,ExternalProcessorClientInterceptordirectly handles the application's request and response types (ReqT,RespT).DataPlaneClientCallandDataPlaneListenerwere generalized to<ReqT, RespT>to avoid compiler-generated synthetic bridge casts toInputStream, which would otherwise result in a runtimeClassCastExceptionwhen sending or receiving application messages.Fixes #13010