feat(router): keep query string by default for redirects#11493
feat(router): keep query string by default for redirects#11493mattklein123 merged 11 commits intoenvoyproxy:masterfrom
Conversation
|
/cc @snowp |
f9511e0 to
92091ae
Compare
zuercher
left a comment
There was a problem hiding this comment.
Thanks! I left a couple comments. Mostly I think we need to carefully consider how this impacts existing configurations.
Also, the release notes section of the pull request template is primarily a prompt to remind developers to consider whether release notes in docs/root/version_history/current.rst need to be updated. I do think we should have a release note for this change. More details are in the PULL_REQUESTS.md file.
There was a problem hiding this comment.
I think this would be a bit easier to follow if current_path was just declared and used within the !path_redirect_.empty() block.
There was a problem hiding this comment.
if path_redirect_ is empty, we would need to set final_path to current_path.
There was a problem hiding this comment.
I'm suggesting that in that final else block you can just use final_path = headers.getPathValue(); and then move the declaration of current_path to just before it's remaining uses.
92091ae to
f834250
Compare
a53dd16 to
2fd7dd3
Compare
zuercher
left a comment
There was a problem hiding this comment.
I think the changes in the router look good modulo some changes around comments.
We should document the relationship between path_redirect and strip_query in api/envoy/api/v2/route/route_components.proto and api/envoy/config/route/v3/route_components.proto. Basically that path_redirect with a query string overrides strip_query. I believe you'll need to run tools/proto_format/proto_format.sh fix to update some generated code or you'll get CI errors.
Please avoid force pushes unless you're fixing a DCO error -- it sometimes causes github to lose track of comments and makes changes harder to follow. We always squash commits to master so the final git history will be clean.
There was a problem hiding this comment.
Let's remove this comment.
I do think it's worth having a brief note near here that explains that the path_redirect_ query string, if any, takes precedence over the request's query string.
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
|
@zuercher really grateful to your detailed guidance! I have updated the comments, please check again. |
zuercher
left a comment
There was a problem hiding this comment.
Sorry. Noticed one more thing. But we have to wait for api shepherds to tag this as approved, anyway.
There was a problem hiding this comment.
Last pass. I should have realized this earlier, but the value we compute for this variable never changes for a given instance of RouteEntryImplBase. I think this should become a const member variable of RouteEntryImplBase. It'll save us a string search on every request that hits a path redirect.
There was a problem hiding this comment.
If we have path_redirect_has_query_ we can also split this if statement and skip searching headers.getPathValue() for a ? when we know we're not going to use it.
a258584 to
2a867e5
Compare
|
@zuercher that's ok. should I ping someone? |
zuercher
left a comment
There was a problem hiding this comment.
cc @envoyproxy/api-shepherds this PR has some comment-only changes to v2 to clarify the change in behavior
|
/lgtm v2-freeze |
|
@mattklein123 do you want a second look at this? |
mattklein123
left a comment
There was a problem hiding this comment.
Thanks a few questions/comments.
/wait
There was a problem hiding this comment.
Can you add some examples here (make sure to add the examples to v3 also)? I've been looking at this for a few minutes and I'm a little confused as to what the current behavior is and what is changing.
There was a problem hiding this comment.
Currently the request's query string will be stripped regardless of the value of strip_query.
With this patch, envoy would only strip the request's query string if path_redirect doesn't contain query string and strip_query is set to true.
If path_redirect contains query string, users will be redirected to the specified path with query string no matter what the value of strip_query is.
There was a problem hiding this comment.
Thanks can you add some actual examples of real paths and what happens to them?
There was a problem hiding this comment.
I think even if we think this is the right thing to do, this needs to be runtime guarded (default can be on). Can you please add a runtime feature flag for this?
There was a problem hiding this comment.
I am not sure how to add a runtime feature flag and what its name should be, could you please provide an example?
There was a problem hiding this comment.
Take a look at some blame/commits that touch this array: https://github.com/envoyproxy/envoy/blob/master/source/common/runtime/runtime_features.cc#L54
There was a problem hiding this comment.
If we have a runtime guard do we need this warning? Should this potentially just be a failure? Again I'm confused as to the behavior.
There was a problem hiding this comment.
| // the path_redirect query string, if any, takes precedence over the request's query string, | |
| // The path_redirect query string, if any, takes precedence over the request's query string, |
|
@mattklein123 do you think I should add a test for the previous behavior(always strip the request's query string)? |
Signed-off-by: knight42 <anonymousknight96@gmail.com>
Signed-off-by: knight42 <anonymousknight96@gmail.com>
Signed-off-by: knight42 <anonymousknight96@gmail.com>
Signed-off-by: knight42 <anonymousknight96@gmail.com>
Signed-off-by: knight42 <anonymousknight96@gmail.com>
Signed-off-by: knight42 <anonymousknight96@gmail.com>
Signed-off-by: knight42 <anonymousknight96@gmail.com>
d4ad4ec to
2c28b44
Compare
Signed-off-by: knight42 <anonymousknight96@gmail.com>
2c28b44 to
73e3734
Compare
|
force push to rebase and resolve conflicts. |
mattklein123
left a comment
There was a problem hiding this comment.
Thank you makes total sense to me now. Just a few small comments. Also friendly request to please never force push as it breaks reviews. Please just merge main and add commits. Thanks!
/wait
| if (Runtime::runtimeFeatureEnabled( | ||
| "envoy.reloadable_features.preserve_query_string_in_redirects")) { |
There was a problem hiding this comment.
Is it possible to not check this twice since you check it during route load? It might not be consistent then. Can we latch the expected behavior in the constructor?
| redirect: { host_redirect: new.lyft.com } | ||
| - match: { path: "/path/redirect/"} | ||
| redirect: { path_redirect: "/new/path-redirect/" } | ||
| - match: { path: "/path/redirect/strip-query/true"} |
There was a problem hiding this comment.
We should have tests for the runtime override set to false also.
Signed-off-by: knight42 <anonymousknight96@gmail.com>
Add tests for turning off feature `envoy.reloadable_features.preserve_query_string_in_path_redirects`. Signed-off-by: knight42 <anonymousknight96@gmail.com>
…11493) Signed-off-by: knight42 <anonymousknight96@gmail.com> Signed-off-by: Yifan Yang <needyyang@google.com>
Signed-off-by: knight42 anonymousknight96@gmail.com
Commit Message: leave query string intact by default(
strip_query: false) when performing path redirect.Additional Description:
I think the current behavior(stripping query by default) is not aligned with the documentation. From the documentation of
path_redirectandstrip_queryfield, I am under the impression that query portion is not considered part of path portion. Additionally, even if we want to strip query for path redirects, we can simply setstrip_queryto true.Risk Level:
Testing: unit test
Docs Changes:
Release Notes: query string is not stripped by default for path redirects
Fixes #11443