-
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
api: add a field in Listener proto to be able to reverse the order of TCP write filters #4889
Conversation
3799e24
to
3ea5d64
Compare
@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 |
@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? |
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 |
It's because the filter manager is owned by the connection which doesn't have access to this config. |
@mattklein123 somehow the |
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? |
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. |
OK another thought after talking with @htuch, you could probably add a temporary function to Connection, such as |
3ea5d64
to
989de30
Compare
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. |
49239d0
to
a23a597
Compare
…rseWriteFilterOrder(). Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
a23a597
to
fcd4fa0
Compare
@htuch @mattklein123 all checks have passed. PTAL? |
There was a problem hiding this 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.
1561c92
to
4d77100
Compare
Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
4d77100
to
fd65ede
Compare
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>
@@ -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)), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
@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? |
@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! |
Got it, thanks for the info! |
… 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>
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