ext_proc: Honor HeaderValueOption.append_action, keep append option as well for backward compatibility #29862
ext_proc: Honor HeaderValueOption.append_action, keep append option as well for backward compatibility #29862Ronnie-personal wants to merge 39 commits intoenvoyproxy:mainfrom
Conversation
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
|
@gbrail @yanjunxiang-google Initially I suspected that this line of code might be the root cause. However, after adding a test, it passed successfully. |
|
There is no issues in the ext_proc code at all as mentioned in : #29861 (comment) You just need to set the header mutation "append" proto field in the ext_proc server header response to true to achieve your needs. Also, the test you added in this PR is to verify Envoy ext_proc filter -> ext_proc server path. However your original issue is in the direction ext_proc server -> Envoy ext_proc filter path. Please check below comments for more details: |
…t, honor append option to avoid breaking change Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
|
/retest |
|
Can any maintainers help on the pipeline issue? The pipeline failed to execute with following error. {"error":"invalid_grant","error_description":"Invalid JWT Signature."}, iss: azure-pipelines@envoy-ci.iam.gserviceaccount.com |
|
|
re ci failure we are following up - but there is not an imminent resolution unfortunately |
@phlax Thanks for the prompt reply! Please let me know when I can restart the test. |
|
/retest |
@phlax Thank you for unblocking the test, I'm able to continue with my work. |
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Co-authored-by: tony-2023 <138949958+tony-2023@users.noreply.github.com> Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
tyxia
left a comment
There was a problem hiding this comment.
Thanks! Let's discuss about the goal of this PR first (as I asked in comment below) since i feel your initial issue with set_cookie should be resolved as long as you set HeaderValueOption.append in existing code.
| enum HeaderAppendAction { | ||
| // This action will append the specified value to the existing values if the header | ||
| // already exists. If the header doesn't exist then this will add the header with | ||
| // already exists and the header is inline header. |
There was a problem hiding this comment.
Let's revert this change in API proto. I didn't mean to change the API here (Sorry if my previous comment in the other thread misleads you)
Basically we don't need to impose additional restriction on it and it can just follow the general rule in header map.
There was a problem hiding this comment.
No problem at all, I will revert it back.
| switch (sh.append_action()) { | ||
| case HeaderValueOption::APPEND_IF_EXISTS_OR_ADD: | ||
| // Check if the header already exists with the same name and value. | ||
| is_duplicate = false; |
There was a problem hiding this comment.
Thanks @htuch !
@Ronnie-personal. As I mentioned above. we should just use addCopy to handle APPEND_IF_EXISTS_OR_ADD. ext_proc doesn't need to detect duplicate header manually as addCopy internally already handles all cases: duplicate inline and non-inline headers as well as set-cookie. This actually leads to a question for you: I am wondering what is the issue this PR aims to address? Using HeaderValueOption.append with existing code should resolve your set-cookie issue as it is using add_copy already. Or you are improving the code by handling different actions inside of HeaderAppendAction
@yanjunxiang-google Regarding your previous question about rejecting malformed mutation. I feel ext_proc doesn't need to reject malformed headers as long as low-level codec reject them. And it will be ext_proc server's responsibility of using right API. For example, single-value header like content-length should not be appended.
With that said, we should (1)make sure the codec rejection behavior and (2) have test like this example to check the bad request.
I agree with you and that's my understanding too. |
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie-personal <76408835+Ronnie-personal@users.noreply.github.com>
|
Can you please help to assess if this is a breaking change? The existing test failed https://dev.azure.com/cncf/envoy/_build/results?buildId=153326&view=logs&j=8c169225-0ae8-53bd-947f-07cb81846cb5&t=d1a98671-b7ba-5fbf-f06c-ff337c010df4&l=609 In the current state, when 'append' is not explicitly specified with a value, header mutation processes the header using 'false' as the append option. envoy/test/extensions/filters/http/ext_proc/mutation_utils_test.cc Lines 88 to 94 in f7c4aac In the updated code, when 'append' does not have a value, header mutation processes the header using 'append_action' option instead. The default value of 'append_action' is 0 (APPEND_IF_EXISTS_OR_ADD). As a result |
|
@Ronnie-personal Yea, that is a breaking change. I have some ideas (probably a bit hacky) about non-breaking approach. But one step back, one important question I have asked here which I think is not answered yet: what is the purpose of this PR? (a)Bug fix(if so, could you elaborate the bug details) OR (b)feature enrichment (if so, do you have example use case?) |
Sorry If I was not clear enough. I replied to your question in #29862 (comment). I would like to understand why initially 'HeaderValueOption.append_action' is added with with four options? |
|
I'm just replying to "what was the purpose of this PR?" Someone changed HeaderValueOption to add a new "append_action" field, with four possible values, in addition to the existing "append" boolean option. However, when that happened, no one updated ext_proc, so it does not honor the new option. I thought it'd be confusing to ext_proc users to have this new option in the proto that ext_proc would ignore, but other code would use, and I suggested implementing it, which is what this PR is about. I would expect (as a user of ext_proc now) that if append_option were set that it would override append, but that if append_option were unset then the append flag would work as it does today, for backward compatibility. It's not clear from the comments whether that's possible. Also, there must be some other part of the codebase that uses this structure to modify headers -- could we find that and merge the codebases together into a library in "common" somewhere? |
Thanks for the clarification, and I agree with you. It's confusing to the end users if append_action is simply ignored by the ext_proc filter.
Initially I implemented a runtime guard which can indicate whether to use append_option or not. But it appears that the runtime guard is not suitable for this use case, as 'append' will not be decommissioned.
I like the idea of common library. |
|
@Ronnie-personal @gbrail , The reason i asked the purpose of this PR is because I want to see if we should allow breaking change here. I think we should not break other users at current state of ext_proc unless it is for fixing existing bug. This PR is not for fixing bug in existing code. I like the idea of common library, but still IMHO it should be under the principle of non-breaking change. Regarding non-breaking approach, here are approaches in my mind Solution 1: Solution 2: One important thing: Solution3: same philosophy as 2 but simpler : To summarize: Add @wbpcode who implemented |
|
OR if other code owners think we can just simply break |
|
@tyxia Thank you so much for the guidance! I like all of your suggestions, especially the solution 1. |
|
@wbpcode I am wondering if you think Solution 1 that I mentioned in this comment could work? Looks like updates to this enum will only break two active users (header_parser and header_mutation). If it doesn't work, if you have any ideas other than solution2/3, please let us know. Basically, i think we want to achieve the goal : Supporting |
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
|
This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Commit Message:
Honor HeaderValueOption.append_action when append does not have a value.
Additional Description:
Modified mutation_utils to apply header changes based on HeaderValueOption.append_action.
[Optional Fixes #Issue] #29861