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

WIP router: implement path rewrite with regex #8462

Closed
wants to merge 5 commits into from

Conversation

cmluciano
Copy link
Member

Co-Authored-By: Gabriel Taylor Russ [email protected]

Signed-off-by: Christopher M. Luciano [email protected]

Description: Support regex path rewrites
Risk Level: Medium, modifies an existing rewrite action
Testing: bazel test //test/common/router:config_impl_test
Docs Changes: TODO
Release Notes: TODO
Fixes #2092

TODO:

  • Add a few base tests for regex path
  • Add a test specifically showing rewrite happening after the RBAC filter

@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #8462 was opened by cmluciano.

see: more, trace.

Copy link
Member Author

@cmluciano cmluciano left a comment

Choose a reason for hiding this comment

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

For reviewers: I'm still trying to figure out why the prefix ends up being wrong once it hits the PrefixPathRewriter.rewrite function. Any help would be greatly appreciated.

source/common/router/config_impl.h Outdated Show resolved Hide resolved
source/common/router/config_impl.h Show resolved Hide resolved
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, some API and structural comments. Is this PR still WiP? If so, please reflect in the title.
/wait

api/envoy/api/v2/route/route.proto Outdated Show resolved Hide resolved
api/envoy/api/v2/route/route.proto Outdated Show resolved Hide resolved
source/common/json/config_schemas.cc Outdated Show resolved Hide resolved
source/common/router/config_impl.h Outdated Show resolved Hide resolved
bool case_sensitive) const {
ASSERT(case_sensitive ? absl::StartsWith(path, matched_path)
: absl::StartsWithIgnoreCase(path, matched_path));
return std::regex_replace(matched_path, pattern_, substitution_);
Copy link
Member

Choose a reason for hiding this comment

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

We don't allow std::regex to be used going forward, see #7878.

Copy link
Member Author

Choose a reason for hiding this comment

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

It it enough to be passing in a type of RE2 or is std::regex_replace itself part of the problem?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please no std::regex of any kind on the data path.

@cmluciano cmluciano changed the title router: implement path rewrite with regex WIP router: implement path rewrite with regex Oct 4, 2019
@stale
Copy link

stale bot commented Oct 11, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 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!

@stale stale bot added stale stalebot believes this issue/PR has not been touched recently and removed stale stalebot believes this issue/PR has not been touched recently labels Oct 11, 2019
@cmluciano
Copy link
Member Author

@htuch I believe the only remaining error failure is

[ RUN      ] RouteConfigurationV2.RegexPrefixWithNoRewriteWorksWhenPathChanged
[2019-10-18 14:32:29.254][1060923][critical][assert] [source/common/router/config_impl.cc:790] assert failure: regex_->match(pathOnly(headers)).
[2019-10-18 14:32:29.254][1060923][critical][backtrace] [bazel-out/darwin-fastbuild/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:83] Caught Abort trap: 6, suspect faulting address 0x7fff6eaa72c6
[2019-10-18 14:32:29.254][1060923][critical][backtrace] [bazel-out/darwin-fastbuild/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:70] Backtrace (use tools/stack_decode.py to get line numbers):
[2019-10-18 14:32:29.254][1060923][critical][backtrace] [bazel-out/darwin-fastbuild/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:71] Envoy version: 0/1.12.0-dev/redacted/DEBUG/BoringSSL
external/bazel_tools/tools/test/test-setup.sh: line 310: 70995 Abort trap: 6           "${TEST_PATH}" "$@" 2>&1

This ASSERT has a comment that I'm wondering about here.

Do you think this is a signal that it should be revisited as to whether this ASSERT is necessary or does it indicate something wrong within the current PR?

@htuch
Copy link
Member

htuch commented Oct 18, 2019

@cmluciano are you clearing the route cache as the comment indicates? You need to do this if you modify path (or any header).

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.

I think we're still waiting for the switch of the pattern match to be based on RegexMatcher and RE2.
/wait

@stale
Copy link

stale bot commented Nov 4, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 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!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Nov 4, 2019
@cmluciano
Copy link
Member Author

Not stale- I had some temporary compilation problems and now I'm working through basing this off of the RE2 library

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Nov 4, 2019
@stale
Copy link

stale bot commented Nov 11, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 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!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Nov 11, 2019
@stale
Copy link

stale bot commented Nov 18, 2019

This pull request has been automatically closed because it has not had activity in the last 14 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!

@stale stale bot closed this Nov 18, 2019
@DevZenFlow
Copy link

Can we re-open this please?

@htuch htuch reopened this Nov 22, 2019
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Nov 22, 2019
@htuch
Copy link
Member

htuch commented Nov 22, 2019

@vikpck reopened, but not would be good to hear from @cmluciano on the plan. I've heard at least 2 folks in the past week in various conversations ask for this :)

@cmluciano
Copy link
Member Author

Thanks for re-opening. I'll be getting back to working on this today.

Christopher M. Luciano added 5 commits November 25, 2019 16:17
Co-Authored-By: Gabriel Taylor Russ <[email protected]>

Signed-off-by: Christopher M. Luciano <[email protected]>
Signed-off-by: Christopher M. Luciano <[email protected]>
Signed-off-by: Christopher M. Luciano <[email protected]>
@stale
Copy link

stale bot commented Dec 2, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 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!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Dec 2, 2019
@lotte-mollie
Copy link

We would really like this functionality as well! Is there an ETA?

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Dec 4, 2019
@htuch htuch added the waiting label Dec 4, 2019
@dio
Copy link
Member

dio commented Dec 8, 2019

We hope to see some TODOs be implemented soon. Meanwhile, seems like you need to merge master? And this: #8462 (review). Thanks!

@stale
Copy link

stale bot commented Dec 15, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 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!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Dec 15, 2019
@dio
Copy link
Member

dio commented Dec 16, 2019

No stale according to my exchange with @cmluciano.

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Dec 16, 2019
@stale
Copy link

stale bot commented Dec 23, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 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!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Dec 23, 2019
@cmluciano
Copy link
Member Author

Not stale

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Dec 23, 2019
@stale
Copy link

stale bot commented Dec 30, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 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!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Dec 30, 2019
@stale
Copy link

stale bot commented Jan 6, 2020

This pull request has been automatically closed because it has not had activity in the last 14 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!

@stale stale bot closed this Jan 6, 2020
@kenske
Copy link

kenske commented Jan 15, 2020

@cmluciano have you been able to make any progress on this?

@jmarantz
Copy link
Contributor

I'm not sure who can take it over, but I would recommend using RE2 for regexes for this rather than std::regex. I think going forward we want to use that wherever possible in Envoy due to better performance and predictability.

lizan pushed a commit that referenced this pull request Feb 26, 2020
Support path rewriting using regular expressions and optionally capture groups.  This PR is like #8462, but using the safe regular expression support.

Risk Level:  Medium, since it slightly modifies the existing `prefix_rewrite` code.
Testing: Unit tests are added to `test/common/router/config_impl_test.cc`, runnable with `bazel test //test/common/router:config_impl_test`
Docs Changes:  Any doc that references `prefix_rewrite` has been changed to reference `regex_rewrite` as well, if appropriate.
Release Notes:  A bullet is added to `docs/root/intro/version_history.rst` mentioning the new support.

Signed-off-by: James Hennessy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api stale stalebot believes this issue/PR has not been touched recently waiting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Support nginx style rewrite rules via rds.RedirectAction
7 participants