-
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
Matchers: Add dynamic metadata to the http inputs #34891
Matchers: Add dynamic metadata to the http inputs #34891
Conversation
Signed-off-by: Vikas Choudhary <[email protected]>
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Vikas Choudhary <[email protected]>
9dfab6e
to
995b21b
Compare
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
07b7fa3
to
7d03b8b
Compare
@vikaschoudhary16 what is still needed to get this forward from draft status? |
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
tests were pending. Now marked ready |
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.
API LGTM. Needs a release note. add @kyessenov to do the code review.
/wait
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
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.
Looks pretty good -> mostly minor comments.
@@ -30,6 +30,7 @@ These input functions are available for matching HTTP requests: | |||
* :ref:`Response header value <extension_envoy.matching.inputs.response_headers>`. | |||
* :ref:`Response trailer value <extension_envoy.matching.inputs.response_trailers>`. | |||
* :ref:`Query parameters value <extension_envoy.matching.inputs.query_params>`. | |||
* :ref:`Metadata <extension_envoy.matching.inputs.dynamic_metadata>`. |
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.
nit: Dynamic metadata
@@ -103,3 +103,48 @@ message ApplicationProtocolInput { | |||
message FilterStateInput { | |||
string key = 1 [(validate.rules).string = {min_len: 1}]; | |||
} | |||
|
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.
Should this be placed into network
inputs? Are you planning to add network input support as well?
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 was not sure. Looked at existing filter state which is defined here in network
input and being used for both http and network. So thought similar we could do with metadata.
Yeah, I would add network input support as well in follow-up
name = "metadata_input_lib", | ||
srcs = ["meta_input.cc"], | ||
hdrs = ["meta_input.h"], | ||
extra_visibility = [ |
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.
delete extra visibility, also why skip on windows?
class MetadataMatchData : public ::Envoy::Matcher::CustomMatchData { | ||
public: | ||
explicit MetadataMatchData(const ProtobufWkt::Value& value) : value_(value) {} | ||
const ProtobufWkt::Value& 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.
note to myself: this is a dangerous capture by reference. I see CEL does the same thing, but we probably need to audit for potential dangling references.
public: | ||
DynamicMetadataInput( | ||
const envoy::extensions::matching::common_inputs::network::v3::DynamicMetadataInput& | ||
inputConfig) |
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.
style: inputConfig -> input_config
const auto& matcher_config = MessageUtil::downcastAndValidate< | ||
const envoy::extensions::matching::input_matchers::metadata::v3::Metadata&>( | ||
config, factory_context.messageValidationVisitor()); | ||
const auto& v = matcher_config.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.
style: v -> value
const envoy::extensions::matching::input_matchers::metadata::v3::Metadata&>( | ||
config, factory_context.messageValidationVisitor()); | ||
const auto& v = matcher_config.value(); | ||
auto value_matcher = Envoy::Matchers::ValueMatcher::create(v, factory_context); |
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.
these two should be const
: value_matcher_(value_matcher), invert_(invert) {} | ||
|
||
bool Matcher::match(const Envoy::Matcher::MatchingDataType& input) { | ||
if (absl::holds_alternative<absl::monostate>(input)) { |
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.
Is this needed with get_if
?
if (auto* ptr = absl::get_if<std::shared_ptr<::Envoy::Matcher::CustomMatchData>>(&input); | ||
ptr != nullptr) { | ||
Matching::Http::MetadataInput::MetadataMatchData* match_data = | ||
dynamic_cast<Matching::Http::MetadataInput::MetadataMatchData*>((*ptr).get()); |
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.
(*ptr).get()
is odd -> doesn't ptr work?
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.
with only ptr
, I get
error: 'std::shared_ptrEnvoy::Matcher::CustomMatchData' is not polymorphic
Changed to ptr->get()
though
@@ -0,0 +1,34 @@ | |||
load( |
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.
Test directory should match the source: dyn_meta_matcher -> metadata
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
/api lgtm |
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
1c827ba
fixes: envoyproxy#34092 --------- Signed-off-by: Vikas Choudhary <[email protected]> Signed-off-by: Martin Duke <[email protected]>
fixes: envoyproxy#34092 --------- Signed-off-by: Vikas Choudhary <[email protected]> Signed-off-by: asingh-g <[email protected]>
fixes: #34092
Commit Message: Add dynamic metadata to the http inputs
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]