-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Turning upstream response into header only downstream response #4800
Comments
Yeah, this is a reasonable thing to add. It would require some thinking on the best way to do this. Fundamentally, the filter needs to be able to change the end_stream field during propagation. This won't be trivial. As an aside, have you tried just having the 0 length data frame sent with end stream true? I suspect most clients will deal with this correctly without complaining, but I'm not sure. |
I think the data frame is being set with end stream true already since the upstream response doesn't have any trailers to begin with (I'm transforming http/1.1 into gRPC). The Go client in particular complains about missing trailers:
The go-grpc debug log line that I posted seems to agree (note the
Does Envoy even allow me to modify the flags on h/2 frames? Or was your suggestion to have upstream set the flag somehow? |
Would a basic outline of the implementation look something like this: Add a function to the callbacks called We could do this by storing an We'd check for an I'm sure I'm missing some details here, but if this sounds reasonable I'd be happy to spend some time to get it working. |
OK, nevermind then. :)
No, we will have to make a code change as you suggest.
I think what you are proposing would work, but I wonder if it would be simpler to have this be a return code from decode/encode headers. Basically something like "continue iteration and end stream." This would avoid introducing another callback function. @alyssawilk WDYT? |
Yeah, I think adding a response code or changing bool end_stream -> bool& end_stream is the way to go. The one other thing we'll have to be careful about is either draining or closing the upstream connection if we send a local end stream without consuming the whole HTTP/1.1 error body. |
This is described in gRPC HTTP2 protocol mapping: So a gRPC response in H2 frames should be either:
Sorry I'm late on this, I think you can use |
Yep, that's what I'm currently doing. It works but it means setting a flag in |
I've been trying to use a StreamEncodingFilter to turn a bad upstream response into a header only gRPC response that sets
grpc-message
to something useful. The point is to provide a understandable error message rather than having the gRPC client attempt to parse what I can tell from the headers is not going to be the correct format.The problem I'm running into is that I'm not able to get the filter to not respond with any DATA frames.
Tried a few things:
sendLocalReply
on the decoder callbacks while inside encodeHeaders. This hits the following assert:and presumably this is a bad idea since it will loop back into my encoder filter again.
Is there a way to do what I'm accomplishing? If not, would it be a reasonable thing to add?
The text was updated successfully, but these errors were encountered: