Skip to content

http: delaying filter stack creation until full headers have been received#3574

Merged
alyssawilk merged 2 commits intoenvoyproxy:masterfrom
alyssawilk:stream_delay
Jun 11, 2018
Merged

http: delaying filter stack creation until full headers have been received#3574
alyssawilk merged 2 commits intoenvoyproxy:masterfrom
alyssawilk:stream_delay

Conversation

@alyssawilk
Copy link
Contributor

This is a precursor to creating a custom filter stack for websocket vs HTTP.

Risk Level: High
All of the integration test pass. I refuse to believe it is this easy.
Testing: suggestions appreciated
Docs Changes: n/a
Release Notes: should we call out we won't create the filter chain for super early errors?

Part of #3301

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Contributor Author

Matt, if you think this is a reasonable point to delay filter creation, could someone on your side canary this? I'm reaaally surprised this didn't crash anything. Alternately feel free to suggest and and all additional testing.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alyssawilk I actually expected it to be about this easy, so I'm not surprised nothing crashed. I have a question though. Once we decide on the proposed implementation I'm happy to do a quick smoke test.

void ConnectionManagerImpl::ActiveStream::decodeHeaders(HeaderMapPtr&& headers, bool end_stream) {
maybeEndDecode(end_stream);
request_headers_ = std::move(headers);
lazilyCreateFilterChain();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Why do we need the lazy init functionality here? IIRC this function will only be called once? Also, I think we will eventually want to do this lower down in this function once we decide if it's WS or not? Should we position it in the final place now? Perhaps above here:

decodeData(nullptr, data, end_stream);

(The downside of putting it there is any local replies in this function would not go through encoding filters... which I guess is an issue, but it seems like if we instantiate here we would need to blow away and recreate for WS which seems worse? Thoughts?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for local replies, there's a TODO to start encoding from the last filter which saw the request. If in the long run we want filters to only see the response if they saw the request I think this is fine. The other option is we can lazily create the chain on any local reply for consistency until we fix that TODO. I'd assumed we'd have other entry points which is one reason I made it a function :-)

I'd prefer we create the filter chain early on in the function. I'd planned on lazilyCreateFilterChain being refactored to look at request_headers_ (and config, to see if the new path is configured) then deciding if it should create websocket or http filter chain, which is why I stuck it immediately after we latch request_headers_. Happy to move it if you think that's better but I would like to land it without the refactor just to keep things as low risk as possible :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think you are going to put inspection logic in the creation function, I think it's fine to keep it where it is. My preference though is to remove the lazy creation logic though until we actually need it? So maybe just a function callout with a comment about lazy creation, etc.?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, are you just asking that we create the filter chain when this function is called, kill off the boolean, and just rename it to createFilterChain? Or to also keep the function and call it where things are created now?

I'm working on the websocket inspection right PR now. I'd hoped to land the deferred creation as a standalone as I saw it as higher risk, but I'm up for whatever

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, are you just asking that we create the filter chain when this function is called, kill off the boolean, and just rename it to createFilterChain?

Yes that's what I mean. Unless I'm missing something, in the current code the lazy creation checking logic will never be exercised (we will only call the creation function once).

@mattklein123 mattklein123 self-assigned this Jun 8, 2018
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Honestly I think this is safe to merge, but I'm happy to smoke test if you want.

@alyssawilk alyssawilk merged commit 1d14b9e into envoyproxy:master Jun 11, 2018
alyssawilk added a commit to alyssawilk/envoy that referenced this pull request Jun 11, 2018
…been received (envoyproxy#3574)"

This reverts commit 1d14b9e.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
alyssawilk added a commit that referenced this pull request Jun 11, 2018
…been received (#3574)" (#3590)

This reverts commit 1d14b9e.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
alyssawilk added a commit to alyssawilk/envoy that referenced this pull request Jun 12, 2018
…rs have been received (envoyproxy#3574)" (envoyproxy#3590)"

This reverts commit 28cea91.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk alyssawilk deleted the stream_delay branch October 10, 2018 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants