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

common: added a field in HCM proto to be able to reverse the order of HTTP encoder filters. #4721

Merged
merged 9 commits into from
Oct 18, 2018

Conversation

qiannawang
Copy link
Contributor

@qiannawang qiannawang commented Oct 14, 2018

Description: Added a field in HCM proto to be able to reverse the order of HTTP encoder filters. The field is set false by default, indicating HTTP encoder 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

Signed-off-by: Qi (Anna) Wang qiwang@google.com

Qi (Anna) Wang added 3 commits October 14, 2018 14:47
By default (false), they have the same order as configed in the filter
chain. If true, their order will be reversed.

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

@htuch could you PTAL?

@htuch htuch self-assigned this Oct 15, 2018

// If true, the order of encoder filters will be reversed to that of filters
// configured in the HTTP filter chain.
bool reverse_encoders_order = 27;
Copy link
Member

Choose a reason for hiding this comment

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

what is the use case? it would be good to have some explanation associated with such settings. Otherwise, we end up having a plethora of "invert_x", "reverse_y" boolean options all over the config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bug fixing in envoy. The design of envoy was to have reserved order of encoder filters to the configuration in the filter chain. However, the current implementation in envoy is not following this order. In order to avoid breaking anyone who depends on this bug, we decided to fix this as an opt-in behavior.

For more details, see #4599

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to link #4599 in the comment for this? It adds valuable context.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have to go to this extreme to preserve backward compatibility for incorrect behavior. It seems counter intuitive, given that the goal of the API is to describe the system (not workarounds for "correct" behavior). Put another way, if those other systems depended on the incorrect behavior, then those systems are also not functioning correctly are they?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As @htuch suggested, we will mark this field deprecated and put in the release note too.

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good, some feedback.


// If true, the order of encoder filters will be reversed to that of filters
// configured in the HTTP filter chain.
bool reverse_encoders_order = 27;
Copy link
Member

Choose a reason for hiding this comment

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

Prefer reverse_encode_order for naming. Also, I think we should annotation this as deprecated and update https://github.com/envoyproxy/envoy/blob/master/DEPRECATED.md

Copy link
Member

Choose a reason for hiding this comment

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

Should we make this BoolValue and change the default to true in near future (after next release)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done with the renaming.

@htuch would you recommend to add the "deprecated" annotation in this change or in another PR when we deprecate the field in that release?

@lizan what would be the difference between bool and BoolValue in this case?

Copy link
Member

Choose a reason for hiding this comment

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

bool is always default to false and you can't differentiate false and unset. with BoolValue you know if it is unset or true or false.

Copy link
Member

Choose a reason for hiding this comment

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

The question is what will be the process when we remove this deprecated field. If at that moment this will be true (true is expected behavior, right?) then BoolValue makes more sense. @htuch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, the h1_capture_direct_response_fuzz_test test is hitting tsan failure after I set the bool filed [depreated = true]. I am wondering if the BoolValue would help with the failure.

https://circleci.com/gh/envoyproxy/envoy/108918?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

Copy link
Member

Choose a reason for hiding this comment

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

It is a flaky one and fix in recent commit, merge master would help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Merging does help, but looks like I rebased it incorrectly and the version history is corrupted :(

Any suggestions to fix this? I guess I can close this PR and create a new one, but wonder if there is a simple solution.

Copy link
Member

Choose a reason for hiding this comment

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

Yes you shouldn't do git rebase but a simple git merge upstream/master. you can checkout the original commit and do git merge again, and then force push to fix this PR, or close and create a new PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works! thanks for the suggestion!

source/common/http/conn_manager_config.h Outdated Show resolved Hide resolved
source/common/http/conn_manager_config.h Show resolved Hide resolved
source/common/http/conn_manager_impl.cc Outdated Show resolved Hide resolved
test/common/http/conn_manager_impl_test.cc Outdated Show resolved Hide resolved
for (auto filter : encoder_filters_) {
EXPECT_CALL(*filter, onDestroy());
if (reverse_encoders_order_) {
for (int i = encoder_filters_.size() - 1; i >= 0; --i) {
Copy link
Member

Choose a reason for hiding this comment

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

Are all the callers of this setup with InSequence to be able to enforce EXPECT_CALL ordering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, as the InSequence is global within a test case for all callers.

test/common/http/conn_manager_impl_test.cc Outdated Show resolved Hide resolved
@rshriram
Copy link
Member

At the very least, if we are going to do this "bugfix", might as well come clean and declare the field as "bugfix_reverse_encoder_order", so that end users don't mistake this for a "new" feature.

I still think providing backward compatibility for a buggy behavior is a strange thing to do

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

htuch commented Oct 16, 2018

Agree with @rshriram that this should be named as a bug fix. I think it's arguably better to support the old behavior here as we can break folks in production who have unexpected encode filter ordering interactions.

In terms of deprecation, let's immediately deprecate the field and update DEPRECATED.md.

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks good, should be ready to ship soon.

@qiannawang qiannawang changed the title Added a field in HCM proto to be able to reverse the order of HTTP encoder filters. common: added a field in HCM proto to be able to reverse the order of HTTP encoder filters. Oct 16, 2018
@qiannawang qiannawang requested a review from zuercher as a code owner October 17, 2018 06:31
@htuch
Copy link
Member

htuch commented Oct 17, 2018

@lizan we are beginning immediate deprecation. Can you explain how defaulting the field to true at the end of the deprecation cycle, at the same time as we remove it, makes more sense? I don't mind either way TBH, just trying to grok the right thing to do here.

@lizan
Copy link
Member

lizan commented Oct 17, 2018

@htuch I don't mind either, if we do default to true and remove at same time, then no difference, if we do remove later there will be less surprise.

@qiannawang looks like you reverted too much? I don't see the deprecation now.

Qi (Anna) Wang added 2 commits October 17, 2018 18:05
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>
@qiannawang
Copy link
Contributor Author

@htuch I don't mind either, if we do default to true and remove at same time, then no difference, if we do remove later there will be less surprise.

@qiannawang looks like you reverted too much? I don't see the deprecation now.

I have added back the deprecation, resolved all comments and changed to use BoolValue from bool.

@htuch PTAL?

… in the proto.

Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
lizan
lizan previously approved these changes Oct 18, 2018
Copy link
Member

@htuch htuch 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 looks almost ready to ship, some final nits.

DEPRECATED.md Outdated Show resolved Hide resolved
@@ -209,6 +209,7 @@ void FilterJson::translateHttpConnectionManager(

JSON_UTIL_SET_BOOL(json_config, proto_config, use_remote_address);
JSON_UTIL_SET_BOOL(json_config, proto_config, generate_request_id);
JSON_UTIL_SET_BOOL(json_config, proto_config, bugfix_reverse_encode_order);
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed? This is just for v1 config, which is now deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

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

All tests pass. @htuch PTAL?

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks @qiannawang, this is great.

@htuch htuch merged commit 0ccc70a into envoyproxy:master Oct 18, 2018
soya3129 pushed a commit to soya3129/envoy that referenced this pull request Oct 19, 2018
… HTTP encoder filters. (envoyproxy#4721)

Added a field in HCM proto to be able to reverse the order of HTTP encoder filters. The field is set false by default, indicating HTTP encoder 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: Yang Song <yasong@yasong00.cam.corp.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.

5 participants