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

[http]: Fine grained path normalization controls implementation #15450

Closed

Conversation

chaoqin-li1123
Copy link
Member

@chaoqin-li1123 chaoqin-li1123 commented Mar 11, 2021

For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md

Commit Message: Currently, envoy apply path normalization in http connection manager. When a path transformation is enabled, it is visible to all the filters and the upstream server. For fine grained control, we want some path normalization to be visible to filter but not the upstream server. The new hcm api(#15044) allow user to split the path transformation for filter use and for forwarding. This PR intends to implement fine grained path normalization control(#6589) based on the new api. This is a draft used to collect opinions early.
Additional Description:
Risk Level: high
Testing: by now only unit test
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]

chaoqin-li1123 added 7 commits March 9, 2021 05:59
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Copy link
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!
I've left a few comments.
I'm not sure if I missed them, but I did not see the tests for PathTransformer::transform.

source/common/http/path_utility.cc Outdated Show resolved Hide resolved
source/common/http/path_utility.cc Outdated Show resolved Hide resolved
source/common/http/path_utility.h Outdated Show resolved Hide resolved
source/common/http/path_utility.h Outdated Show resolved Hide resolved
source/common/http/path_utility.h Show resolved Hide resolved
source/common/http/path_utility.cc Outdated Show resolved Hide resolved
@yanavlasov yanavlasov self-assigned this Mar 12, 2021
@yanavlasov
Copy link
Contributor

I wonder if this should be moved into the HeaderMap API. I.e. the HeaderMap API would provide two methods. NormalizedPath would return path normalized for matching and the Path would return path for forwarding.

Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
@chaoqin-li1123
Copy link
Member Author

I wonder if this should be moved into the HeaderMap API. I.e. the HeaderMap API would provide two methods. NormalizedPath would return path normalized for matching and the Path would return path for forwarding.

I think we want to configure it in http connection manager.

@chaoqin-li1123
Copy link
Member Author

I wonder if this should be moved into the HeaderMap API. I.e. the HeaderMap API would provide two methods. NormalizedPath would return path normalized for matching and the Path would return path for forwarding.

I see, I do plan to store both the path for filter use and path for forwarding in HeaderMap.

Copy link
Contributor

@asraa asraa left a comment

Choose a reason for hiding this comment

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

Thanks so much!!

source/common/http/path_utility.cc Outdated Show resolved Hide resolved
source/common/http/path_utility.cc Show resolved Hide resolved
source/common/http/path_utility.h Outdated Show resolved Hide resolved
source/common/http/path_utility.cc Show resolved Hide resolved
chaoqin-li1123 added 4 commits March 12, 2021 15:55
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Copy link
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!
Added a few comments.

return;
PathTransformer::PathTransformer(envoy::type::http::v3::PathTransformation path_transformation) {
const auto& operations = path_transformation.operations();
std::vector<uint64_t> operation_hashes;
Copy link
Contributor

Choose a reason for hiding this comment

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

Depending on the length, it might be better to use absl::flat_hash_set.

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 might be overkill to use a hash set here since we expect a very small number of transformation.

source/common/http/path_utility.cc Outdated Show resolved Hide resolved
source/common/http/path_utility.cc Outdated Show resolved Hide resolved
source/common/http/path_utility.cc Show resolved Hide resolved
source/common/http/path_utility.cc Show resolved Hide resolved
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
chaoqin-li1123 added 3 commits March 15, 2021 16:42
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
@@ -480,7 +485,8 @@ class RequestHeaderMapImpl final : public TypedHeaderMapImpl<RequestHeaderMap>,
};

using HeaderHandles = ConstSingleton<HeaderHandleValues>;

std::string forwarding_path_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the intended use for these two be documented?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense.


// Take a string_view as argument and return an optional string.
// The optional will be null if the transformation fail.
absl::optional<std::string> transform(const absl::string_view original_path) const;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: could you mention that this will execute all configured transformations, or something along those lines?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, will add comments.

Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
chaoqin-li1123 added 5 commits March 18, 2021 16:44
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
@chaoqin-li1123 chaoqin-li1123 changed the title [WIP]: Fine grained path normalization controls implementation [http]: Fine grained path normalization controls implementation Mar 23, 2021
chaoqin-li1123 added 3 commits March 23, 2021 19:22
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
@@ -807,6 +814,14 @@ class RequestHeaderMap
public:
INLINE_REQ_STRING_HEADERS(DEFINE_INLINE_STRING_HEADER)
INLINE_REQ_NUMERIC_HEADERS(DEFINE_INLINE_NUMERIC_HEADER)
virtual absl::string_view getForwardingPath() PURE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add comments explaining what these methods are for.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, will fix.

source/common/http/conn_manager_utility.cc Outdated Show resolved Hide resolved
source/common/http/conn_manager_utility.cc Outdated Show resolved Hide resolved
@chaoqin-li1123
Copy link
Member Author

cc @yangminzhu

chaoqin-li1123 added 3 commits March 26, 2021 04:09
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
@chaoqin-li1123
Copy link
Member Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #15450 (comment) was created by @chaoqin-li1123.

see: more, trace.

Signed-off-by: chaoqin-li1123 <chaoqinli@google.com>
@github-actions
Copy link

github-actions bot commented May 9, 2021

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!

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label May 9, 2021
@github-actions
Copy link

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!

@github-actions github-actions bot closed this May 16, 2021
@chaoqin-li1123
Copy link
Member Author

reopen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants