Skip to content
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

api: add a field in Listener proto to be able to reverse the order of TCP write filters #4889

Merged
merged 5 commits into from
Nov 12, 2018

Conversation

qiannawang
Copy link
Contributor

Description: Add a field in listener proto to be able to reverse the order of TCP write filters. The field is set false by default, indicating write filters have the same order as configured in the filter chain. If true, their order will be reversed.
Risk Level: Low
Testing: bazel test //test/...
Part of #4599

@qiannawang qiannawang force-pushed the httpfilter branch 2 times, most recently from 3799e24 to 3ea5d64 Compare October 29, 2018 08:21
@qiannawang
Copy link
Contributor Author

@mattklein123 @htuch: could you take a look while I am fixing the test?

As suggested in [1], I added field in the FilterChain. However, this proto is not passed to the filter manager class, which determines the order of write filters. I passed a bool variable through many layers and changed 50+ files as you see. I wonder if there is a better solution to pass this info to the filter manager.

[1] #4599

@mattklein123
Copy link
Member

@qiannawang hmm yeah. I just took a quick look and agree this is very ugly. The only thing I can think of would be to have a global server/bootstrap option for this, and pass that option into the dispatcher, which could then be passed into Connection/FilterManager construction so it can be hidden from everywhere else?

Or more horribly even a deprecated CLI option so it would be an effective global? Just trying to think of least amount of change that we can do for something we are going to turn around and remove.

@htuch thoughts?

@htuch
Copy link
Member

htuch commented Oct 29, 2018

I'm not sure why this had to become part of the factory interface for filters? Don't we just want this to be in Network::FilterChain? Most of the delta seems to be because we're modifying the filter API here.

@mattklein123
Copy link
Member

It's because the filter manager is owned by the connection which doesn't have access to this config.

@htuch
Copy link
Member

htuch commented Oct 29, 2018

@mattklein123 somehow the FilterManager mus be obtaining a list of filter factories. Can't we just change this to (filter factory list, reversal flag) without modifying the filter factory API?

@mattklein123
Copy link
Member

Unfortunately not unless I am missing something. The "filter manager" is owned by the connection and is used to add filters as part of the listener manager config build.

One option would be to do the logic for this slightly differently. Instead of switching push_front with push_back (or however it was done previously), actually change the order by which the filters are added at the network level. I think this could be done directly from the listener manager w/o all these changes?

@mattklein123
Copy link
Member

Sorry nevermind my previous comment, that won't work, as we don't know what a factory will do when it's called in terms of encode/decode/both.

I don't see any way around making all these changes or doing some type of global/bootstrap option.

@mattklein123
Copy link
Member

OK another thought after talking with @htuch, you could probably add a temporary function to Connection, such as reverseEncodeOrder() and call it from ListenerImpl::createNetworkFilterChain. That could be plumbed into the filter manager and avoid a bunch of other changes? I think it would still require a Connection interface change unless we somehow get the property into the dispatcher directly.

@htuch htuch self-assigned this Oct 30, 2018
@qiannawang qiannawang closed this Nov 5, 2018
@qiannawang
Copy link
Contributor Author

thanks for the suggestions, @mattklein123 and @htuch. I will make the suggested changes according.

I will add a field in Listener instead of FilterChain to guard the enable/disable of reversing write filter order.

@qiannawang qiannawang reopened this Nov 6, 2018
@qiannawang qiannawang force-pushed the httpfilter branch 2 times, most recently from 49239d0 to a23a597 Compare November 6, 2018 05:14
…rseWriteFilterOrder().

Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
@qiannawang
Copy link
Contributor Author

@htuch @mattklein123 all checks have passed. PTAL?

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.

Thanks, this is great, much simpler. A few small comments.

ci/.bazelrc Outdated Show resolved Hide resolved
include/envoy/network/connection.h Show resolved Hide resolved
Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
include/envoy/network/connection.h Show resolved Hide resolved
DEPRECATED.md Outdated Show resolved Hide resolved
Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
@@ -135,7 +135,7 @@ HttpConnectionManagerConfig::HttpConnectionManagerConfig(
Server::Configuration::FactoryContext& context, Http::DateProvider& date_provider,
Router::RouteConfigProviderManager& route_config_provider_manager)
: context_(context), reverse_encode_order_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, bugfix_reverse_encode_order, false)),
config, bugfix_reverse_encode_order, true)),
Copy link
Member

Choose a reason for hiding this comment

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

It scares me that this change has no test implications? I guess because we have no integration test which covers this case? Can you potentially open a tech debt issue for someone to add a multi-filter encode/decode integration test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are tests validating this. No test violation because we have set the default value true in the test, exercising the reversed order, see

bool reverse_encode_order_{true};

Copy link
Member

Choose a reason for hiding this comment

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

The tests are not actually validating this code change here, which is the real HCM config. (The tests use a mock/fake config.). This is why no other test changes were required when you made this change. Please add a config test here that would have failed with this change: https://github.com/envoyproxy/envoy/blob/master/test/extensions/filters/network/http_connection_manager/config_test.cc. Also please open the integration test tech debt issue I mentioned. We should have an integration test that uses multiple encode/decode filters. This should be a lot easier now given all the work that both @alyssawilk and @snowp have done with fake filters recently.

Copy link
Contributor Author

@qiannawang qiannawang Nov 12, 2018

Choose a reason for hiding this comment

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

Added a test case in config_test.cc to validate the hcm config, as well as a case in listener_manager_impl_test.cc to validate the listener config.

IMO, the tests in
https://github.com/envoyproxy/envoy/blob/master/test/common/http/conn_manager_impl_test.cc
plus,
https://github.com/envoyproxy/envoy/blob/master/test/extensions/filters/network/http_connection_manager/config_test.cc
are sufficient. The former validates cases of multiple (mock) encode/decode filters, with a fake hcm config. The latter (newly added case) validates the hcm config is set from the proto.

I think the case, which is not tested as an e2e definition, is to consume the real hcm config from the proto and bring up real filters. If we are going to use fake filters in the e2e, the test cases seem already sufficient for me.

Let me know if my understanding is correct. Happy to file a new issue for test tech debt if there is a need.

Copy link
Member

Choose a reason for hiding this comment

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

Yes I think this is fine, via the work that @snowp is doing now in the other PR we should be able to easily get coverage of multiple encoder filters in an integration test which is great.

Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
@@ -8,7 +8,8 @@ A logged warning is expected for each deprecated item that is in deprecation win

## Version 1.9.0 (pending)

* Order of execution of the encoder filter chain has been reversed. Prior to this release cycle it was incorrect, see [#4599](https://github.com/envoyproxy/envoy/issues/4599). In the 1.9.0 release cycle we introduced `bugfix_reverse_encode_order` in [http_connection_manager.proto] (https://github.com/envoyproxy/envoy/blob/master/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto) to temporarily support both old and new behaviors. Note this boolean field is deprecated.
* Order of execution of the network write filter chain has been reversed. Prior to this release cycle it was incorrect, see [#4599](https://github.com/envoyproxy/envoy/issues/4599). In the 1.9.0 release cycle we introduced `bugfix_reverse_write_filter_order` in [lds.proto] (https://github.com/envoyproxy/envoy/blob/master/api/envoy/api/v2/lds.proto) to temporarily support both old and new behaviors. Note this boolean field is deprecated.
* Order of execution of the HTTP encoder filter chain has been reversed. Prior to this release cycle it was incorrect, see [#4599](https://github.com/envoyproxy/envoy/issues/4599). In the 1.9.0 release cycle we introduced `bugfix_reverse_encode_order` in [http_connection_manager.proto] (https://github.com/envoyproxy/envoy/blob/master/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto) to temporarily support both old and new behaviors. Note this boolean field is deprecated.
Copy link
Member

Choose a reason for hiding this comment

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

Do you have a PR to default this true for consistency, given the new default approach that was agreed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both fields for write and encoder filters, respectively, are default true in this PR. Should I explain more explicitly about the default value in the DEPRECATED.md file?

Copy link
Member

Choose a reason for hiding this comment

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

That's fine as is then.

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.

Thanks for working on this, LGTM. Will defer to @htuch for further review and merge.

@htuch htuch merged commit 5da782c into envoyproxy:master Nov 12, 2018
@qiannawang
Copy link
Contributor Author

@mattklein123 @htuch, can I start now the cleanup and remove the proto fields and interfaces I added for this bug fix? Or should I wait for some time? If the latter, how long should I wait?

@mattklein123
Copy link
Member

@qiannawang we do deprecation cleanups after we snap the next release. So in this case, after we snap 1.9.0 which will be 1.5 months or so. When we do the release we will automatically create cleanup tickets and assign them to you. Thank you!

@qiannawang
Copy link
Contributor Author

Got it, thanks for the info!

fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
… TCP write filters (envoyproxy#4889)

Add a field in listener proto to be able to reverse the order of TCP write filters. The field is set false by default, indicating write filters have the same order as configured in the filter chain. If true, their order will be reversed.

Risk Level: Low
Testing: bazel test //test/...
Part of envoyproxy#4599

Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
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.

3 participants