Conversation
| const StreamInfo::StreamInfo& stream_info) { | ||
| if (!http_request_started_) { | ||
| return; | ||
| onCreate(); |
There was a problem hiding this comment.
I think it is better to have something like
EnsureContext function, it is very confusing to read that log calls on create.
There was a problem hiding this comment.
/cc @jplevyak
This is because http request is not started...
How about something like this in a "EnsureContext" function?
if (asContext()==nullptr) {
onCreate();
}
There was a problem hiding this comment.
This is a problem with the Envoy interface, so we should not be hacking a patch into the proxy-wasm-cpp-host library. The contract is that onCreate should be called before any other functions are called which require a VM context are called. That was an explicit and intentional design decision. It is up to the Envoy interface code to ensure that all calls into the VM which require a context are bracked with onCreate and onDestroy. It is confusing to see that log() calls onCreate, but that is because Envoy does not have a well defined lifetime for the combined HTTP + AccessLog filter. The solution is the work around this limitation by either 1) not calling into the VM if the Context is not already created (this is the solution which we took earlier and which we now have discovered doesn't work for your use case), or 2) create the VM Context on demand when it is needed for the log() case (as is being done here).
This was discussed with Harvey and it was the decision that Wasm should attempt to fixup the lifetime issues for Envoy Filters to the extent possible. It might be better if we could have a full lifecycle, but sendLocalReply short-circuits that so instead we have a log() call coming without the onRequestHeaders() call which would normally preface it so we can add the onCreate() call here as needed.
There was a problem hiding this comment.
Please add a long winded comment about why we are doing this, including an explicit mention of sendLocalReply and the way that it short circuits the lifecycle of the filter.
There was a problem hiding this comment.
@jplevyak i understand, in that case it is just naming issue.
If (!context_created) {
OnCreate();
}
?
There was a problem hiding this comment.
in_vm_context_created_ is already available in the ContextBase superclass object. You could use that.
There was a problem hiding this comment.
Done... ptal
I changed http_request_started to in_vm_context_created_. @jplevyak : I don't think there are there any cases where http_request_started is false and we don't want to call onLog?
There was a problem hiding this comment.
Looks fine. Just a couple of questions to make sure it's working as-intended:
- is onDestroy still called in the exceptional case?
- do we need to worry about server-first protocols (onResponse called before onRequest)?
|
/retest |
|
@gargnupur @jplevyak is asan failure real? |
Signed-off-by: gargnupur <gargnupur@google.com>
@mandarjog : looks like not... |
|
Seems like a timeout @mandarjog |
Signed-off-by: gargnupur gargnupur@google.com
For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md
Commit Message: Don't return in log, if request is not started. We miss cases like localReply in that scenario
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]