-
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
common: added a field in HCM proto to be able to reverse the order of HTTP encoder filters. #4721
Conversation
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>
@htuch could you PTAL? |
|
||
// 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; |
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.
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
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.
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
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.
Does it make sense to link #4599 in the comment for this? It adds valuable context.
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.
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?
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.
As @htuch suggested, we will mark this field deprecated and put in the release note too.
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! 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; |
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.
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
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.
Should we make this BoolValue and change the default to true in near future (after next release)?
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 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.
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.
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 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?
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.
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.
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 is a flaky one and fix in recent commit, merge master would help.
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.
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.
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 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.
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 works! thanks for the suggestion!
for (auto filter : encoder_filters_) { | ||
EXPECT_CALL(*filter, onDestroy()); | ||
if (reverse_encoders_order_) { | ||
for (int i = encoder_filters_.size() - 1; i >= 0; --i) { |
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.
Are all the callers of this setup with InSequence
to be able to enforce EXPECT_CALL
ordering?
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, as the InSequence is global within a test case for all callers.
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>
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. |
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.
Looks good, should be ready to ship soon.
api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto
Outdated
Show resolved
Hide resolved
@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. |
@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. |
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>
I have added back the deprecation, resolved all comments and changed to use BoolValue from bool. @htuch PTAL? |
api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto
Show resolved
Hide resolved
… in the proto. Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
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 looks almost ready to ship, some final nits.
api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto
Outdated
Show resolved
Hide resolved
source/common/config/filter_json.cc
Outdated
@@ -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); |
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.
Why is this needed? This is just for v1 config, which is now 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.
Removed.
Signed-off-by: Qi (Anna) Wang <qiwang@qiwang-macbookpro.roam.corp.google.com>
All tests pass. @htuch 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 @qiannawang, this is great.
… 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>
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