[http] Remove exceptions from HTTP/1 codec callbacks#11101
[http] Remove exceptions from HTTP/1 codec callbacks#11101jmarantz merged 6 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Asra Ali <asraa@google.com>
Signed-off-by: Asra Ali <asraa@google.com>
Just to make sure we are all on the same page, what is the plan for the "application error" exceptions? I don't really know what the caller would do with an error other than crash, and adding return code from encodeHeaders would be a larger change. Can we just PANIC/RELEASE_ASSERT in those cases for now? |
Hmm yeah I'm happy to RELEASE_ASSERT, since that's preserving existing behavior, but I think I had some feedback to change this as I remove exceptions. Would you imagine some error status handling in |
I honestly don't know what that would be. If we insist in not crashing in these cases the only thing I can think of to do would be to ASSERT and then continue on to fill in some default values or something. |
| "envoy.reloadable_features.reject_unsupported_transfer_encodings")), | ||
| output_buffer_([&]() -> void { this->onBelowLowWatermark(); }, | ||
| [&]() -> void { this->onAboveHighWatermark(); }), | ||
| dispatching_(false), output_buffer_([&]() -> void { this->onBelowLowWatermark(); }, |
There was a problem hiding this comment.
I feel like the global capture could have unexpected costs as the code evolves. I think it's OK for tests, but WDYT of making this prod code explicitly capture what it needs?
There was a problem hiding this comment.
I'm unfamiliar with this code, but I think the reason why it was written like that was because client/server would need to capture a disjoint set of things. Could pass both active request/pending response in, I can try to
There was a problem hiding this comment.
oh, sorry. I misread the diff and thought you had added this. I'm not crazy about it but it's pre-existing so lgtm.
| sendProtocolError(Http1ResponseCodeDetails::get().InvalidUrl); | ||
| throw CodecProtocolException("http/1.1 protocol error: invalid url in request line"); | ||
| ASSERT(codec_status_.ok()); | ||
| ENVOY_LOG_MISC(info, "SETTING PROTOCOL ERROR"); |
There was a problem hiding this comment.
did you plan to leave this in? If so, can you include the URL?
There was a problem hiding this comment.
done -- but actually this was useful for debugging. What do you think about adding logging statements when the codec_status_ sets an error?
This ends up getting logged when onData calls dispatch, but that was too late for any codec level test debugging. At that point I might want to wrap the whole pattern of
ASSERT(codec_status_.ok());
codec_status_ = .... ;
ENVOY_LOG_MISC(trace, codec_status_.message);
into one thing.
There was a problem hiding this comment.
When debugging something in the heat of the moment, more logs are great, as long as the quantity of logs doesn't become a problem. I only suggest that if there's a URL to log, we include that.
Signed-off-by: Asra Ali <asraa@google.com>
Signed-off-by: Asra Ali <asraa@google.com>
|
Sounds like a perfect use of ENVOY_BUG (assert in debug mode, log error
with N^2 backoff in opt) with error handling - wasn't someone going to look
into that this quarter?
…On Thu, May 7, 2020 at 2:58 PM Matt Klein ***@***.***> wrote:
Would you imagine some error status handling in sendLocalReply and other
callers of encodeHeaders?
I honestly don't know what that would be. If we insist in not crashing in
these cases the only thing I can think of to do would be to ASSERT and then
continue on to fill in some default values or something.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11101 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AELALPNPOXAIKHJDKEXS5WDRQMAEXANCNFSM4M3P56KQ>
.
|
Signed-off-by: Asra Ali <asraa@google.com>
Yes, agreed, if there is a sane default behavior we can agree on this is a fine use case of that paradigm IMO. |
mattklein123
left a comment
There was a problem hiding this comment.
Thanks this LGTM at a high level so will defer to others for detailed review. Nice work!
jmarantz
left a comment
There was a problem hiding this comment.
basically looks great, modulo the [&] capture and some commenting around the significance of the specific status codes ints.
|
|
||
| bool resetStreamCalled() { return reset_stream_called_; } | ||
|
|
||
| // The following define special return values for http_parser callbacks. |
There was a problem hiding this comment.
put in the comment here where these constants come from, and maybe that they need to not overlap with standard HTTP Status codes?
There was a problem hiding this comment.
Thanks -- one clarification: you said "These codes do not overlap with standard HTTP Status codes". Is it also correct to strengthen that to "These codes must not overlap with standard HTTP Status codes"? Or are they unrelated?
There was a problem hiding this comment.
Unrelated. They're return values for the user defined callbacks for the parser, so they don't do anything but signal execution flow for the parser.
There was a problem hiding this comment.
Maybe "The use of these codes are distinct from standard HTTP Status codes"
|
/wait |
Signed-off-by: Asra Ali <asraa@google.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s), but failed to run 2 pipeline(s). |
…oxy#11101)" This reverts commit 3550a7a. Signed-off-by: Asra Ali <asraa@google.com> Signed-off-by: asraa <asraa@google.com>
…oxy#11101)" This reverts commit 3550a7a. Signed-off-by: Asra Ali <asraa@google.com>
Commit Message: Remove all throw statements from H/1 codec This change removed all uses of C++ exceptions from H/1 codec. I modeled the flow after Yan's H/2 work (#11575). Codec status are set in uniform helper methods. This is the only change from the previous PR (#11101), besides merging newer exceptions. This change replaces all throw statements with a return of corresponding error Status and adds plumbing to return the status to codec callers. The dispatch() method returns the encountered error to the caller, which will be handled accordingly. The calls to the RequestEncoder::encodeHeaders() NOT called from dispatch() method will RELEASE_ASSERT if an error code is returned. This does not alter the existing behavior of abnormally terminating the process, just the method of termination: RELEASE_ASSERT vs uncaught exception. Risk Level: High (Codec changes) Signed-off-by: Asra Ali <asraa@google.com>
Commit Message: Remove exceptions from HTTP/1 codec callbacks. Replaces with http_parser exit codes that indicate failure.
codec_status_propagates the error.Additional Description:
ASSERT(dispatching_)in the body of the method that throws, alwaysASSERT(codec_status_.ok())before setting the codec status.encodeHeaders, which I will need to replace withENVOY_BUGcodec_impl, but I will need to do another pass.encodeHeadersand any other utility functions. This is just a PR to stage.Testing: Tests pass,
codec_impl_fuzz_testhas been running for a few minutes.Risk level: Medium, this should do nothing but is a codec behavior change.
Issues: #10878
Signed-off-by: Asra Ali asraa@google.com