-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: add ability to add/remove query parameters #33977
http: add ability to add/remove query parameters #33977
Conversation
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Derek Argueta <darguetap@gmail.com>
some TODOs I'd like to get into this PR:
|
Rather than to implement this in our core code path (and core route API), considering we have a full featured L7 filter chain, I will prefer to implement this in a filter like /wait-any |
@wbpcode I had asked about that here as I began working on this: #2098 (comment) |
I don't disagree though, if that's the desired direction I can pivot. |
@derekargueta sorry, I forgot to check the original issue and related comments and different maintainers may have different ideas. IMO, I will still recommend to implement it as part of HTTP filter. (I think you can implement it the exist
cc @mattklein123 for more inputs. |
@wbpcode no worries! yeah after sleeping on it another advantage that came to mind might be ability to modify query parameters before/after certain filters. I don't have a concrete use-case in mind but might be useful to add parameters after certain operations e.g. auth/rate-limiting to compose higher level functionality by controlling the order of filters.
interesting thought, I was initially thinking of just a new |
I don't feel that strongly about it. If you both feel it would be better to do it as a filter that is fine with me. I just figured all the rest of this stuff is already in the router but this doesn't have to be. |
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
See #34550 for our latest common API for all these map-like mutations. :) To use the new common API, I think you only need only to change the type of proto and needn't much change to the code. |
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.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.
Oh, thanks for the update. Some comments to the API is added.
api/envoy/config/core/v3/base.proto
Outdated
bytes value = 2; | ||
string value = 2; |
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.
Please no. bytes
is used here by design.
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.
doh, left an unsent github comment. I was wondering about the use of bytes
? IIUC this makes command substitution a no-go which is the primary use-case I have in mind (appending a query param from metadata). It also seems inconsistent - elsewhere I see an option for a value
string and a raw_value
bytes.
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.
IIUC this makes command substitution a no-go which is the primary use-case I have in mind (appending a query param from metadata).
The bytes
is used to support non-UTF8. But I think it's also OK to use it as a command formatter for Envoy. But it may not be Okay for non-C++ xDS clients.
@htuch WDYT? should we use string value as value with command formatter and use bytes value as raw value?
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.
Strings/bytes on the wire are identical. How we opt to use them then comes down to the Envoy implementation. Can you elaborate on how "command substitution" is working here? It looks like regular header or parameter append operation etc.
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's same as the HeaderValue
message. The value
field may be a string with substitution formatter like %REQ(CUSTOM-KEY)%
. bytes
should be fine for C++ xDS client like Envoy in this scenario, because bytes
and string has no essential difference in C++. But not sure if it's OK for non-C++ client, like go gRPC proxy.
cc @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.
const auto value_option = mutation.append(); | ||
const auto key = value_option.entry().key(); | ||
const auto value = value_option.entry().value(); | ||
const auto formatter = std::make_unique<Formatter::FormatterImpl>(value, true); |
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.
Please initialize the formatter when loading configuration to avoid do this at runtime.
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 formatter needs the value
?
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.
Yeah, you need to parse the value when you constructing QueryParamsEvaluator
. Creating the formatter will bring big overhead and my throw exception. It's not allowed to do that at key data path.
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 think this is problem is still not be resolved.
We should load/create the formatter when loading configuration.
You can take the header mutations implemention as an example.
/lgtm api
/wait
api/envoy/extensions/filters/http/header_mutation/v3/header_mutation.proto
Outdated
Show resolved
Hide resolved
Signed-off-by: Derek Argueta <darguetap@gmail.com>
Signed-off-by: Derek Argueta <darguetap@gmail.com>
/wait |
Signed-off-by: Derek Argueta <darguetap@gmail.com>
@wbpcode gentle ping, also @derekargueta it seems need a merge with main also |
I have to say sorry to the @derekargueta . Now, this is blocked by the API. We may did incorrect decision in past about the API. And I will try give a final conclusion next week early. |
/wait-any Temporary label and well update it tomorrow. |
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: Add ability to add/remove query parameters.
Additional Description:
Risk Level: Low
Testing: Included
Docs Changes: Included
Release Notes: Included
Platform Specific Features: N/A
Fixes: #2098
Signed-off-by: Derek Argueta darguetap@gmail.com