-
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
[Proposal] WIP: Add support for setDynamicdata (#15148) #15196
Conversation
Hi @Gsantomaggio, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
a5d1b6b
to
a7a88ac
Compare
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 option is preferable, but the same path should be used for both get
and set
operations.
I believe that you can already retrieve dynamic metadata using:
self.get_property(vec!["metadata", "filter_metadata", "envoy.filters.network.rbac", "something"]);
so the same path should be used for the set
operation.
Agree with @PiotrSikora and we don't need to introduce new property tokens here, and this should be aligned with existing getProperty(["metadata",...]) call. |
@mathetake we will remove the What we are still trying to understand is how to distinguish The We'd like to add this feature given the same interface How would you set the metadata and dynamic metadata using the for example in rust SDK is something like: self.set_property(vec!["metadata", "filter_state", .... ], Some("value".as_ref())); How would be for dynamic metadata? Thank you |
@kyessenov could you help with this? |
fields_a[v1].set_bool_value(true); | ||
std::string key3; | ||
absl::StrAppend(&key3, path); | ||
stream_info->setDynamicMetadata(key3, metadata_val); |
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.
Unclear how key and value are derived.
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.
That what just a test, the problem is how to pass ProtobufWkt::Struct metadata_val
client side:
I was thinking something like:
ProtobufWkt::Struct metadata_val;
std::string json_string;
absl::StrAppend(&json_string, value);
MessageUtil::loadFromJson(json_string, metadata_val);
stream_info->setDynamicMetadata(key, metadata_val);
and client side send a JSON
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.
JSON sounds fine, although it's parsing is pretty slow. Using dynamic metadata has inherent performance issues, so it might be ok with parsing. WDYT @PiotrSikora ?
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.
Hi @kyessenov, thanks for the review! I'm working with Gabriele on this proposal. My understanding now is that we can expect value
to always be a JSON string (assuming the parsing performance is acceptable) when path
starts with metadata\0
. Is my understanding correct?
In such case, should we return WasmResult::BadArgument
if the string is not JSON-parsable?
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.
We changed the PR, the idea is to parse the path, identify the metadata and set the dynamic metadata.
client side would be:
self.set_property(vec!["metadata","my.filters.network.network"], Some("{\"noaccess\": true}".as_ref()));
cc @kyessenov
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 that using JSON to set_property
like the above for metadata does not match the intuition of getting back JSON from get_property
with metadata - in particular, get_property
can get you a protobuf struct when asking just for vec!["metadata"]
or or a "pairs" length and 0-delimited key-value array without type information for values if you specify a path after "metadata" (at least for the use cases I've had).
I think there is some work to be done in this area to define what is expected in both directions.
Signed-off-by: Gabriele Santomaggio <[email protected]>
a7a88ac
to
ad1e313
Compare
The PR is ready for another round, we'd like to understand if the idea is valid before go ahead with tests etc.. |
|
@PiotrSikora @kyessenov Can we read dynamic metadata that is set from a previous filter ? I'm trying to access dynamic metadata that is set from ext_authz as protobuf::struct. I'm doing the following but it's not working. google::protobuf::Struct metadata;
if (!getMessageValue(
{"metadata", "filter_metadata", "envoy.filters.http.ext_authz"}, &metadata)) {
LOG_ERROR(std::string("filter_metadata Error ") + std::to_string(id()));
}
It logs the error. When I trace the ext_authz response, I can see metadata there. So I guess I'm doing something wrong with reading it from my filter. |
@PiotrSikora this PR is waiting for quite sometime now. We need this capability. Please advise if anything missing to continue the review |
I understand @PiotrSikora may be buried in other efforts, would any other @envoyproxy/wasm-dev folks be available to comment on this proposal? There is additional work to be done around test dev, if the proposal is generally acceptable. |
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.
@Gsantomaggio sorry for the delay!
At the very least, you need to add tests with a round-trip set
/get
example to see how this could be used in practice.
Regarding JSON - we don't really use it across ABI boundary, and get_property
returns serialized list of pairs (at least for the filter_state
), so as @unleashed already pointed out, set_property
should use the same format.
@PiotrSikora IMO using pairs is quite the limitation, as we lose type information and the need to deal with ambiguities is pushed over to the wasm modules. For example, distinguishing between a value that could be both a string or an array of strings becomes an interesting problem, as some values could be valid interpreted as both types. I think keeping this type information is important here, though I'd prefer it if it was kept using protobuf rather than JSON. |
@unleashed I agree, but we need to be consistent between getters and setters. In general, As for this issue, I think we should introduce If that sounds reasonable, then you can search for |
thank you @PiotrSikora I was already working on something like that as a second option: We have also a second option to solve the issue by adding another method
self.set_dynamicdata(vec!["rabbitmq.filters.network"],
Some("items".as_ref()));
} |
@Gsantomaggio oh, that's right! Sorry for initially sending you on the wrong path. As for those commits, since this is an Envoy specific extension, you should be able to implement everything in this repo, without touching Proxy-Wasm C++ Host. Please take a look at Also, you need to add getters, and ideally do the same for the |
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! |
Is there still interest in working on this? I don't know whether it's been dealt with elsewhere, but if not it looks to me like this is an important missing feature for these modules. |
@unleashed at the moment I can't work on it. Hope to restart working on it in the next months. |
Hi @Gsantomaggio , is there a specific rust implementation code for second option? Or is there a runnable git demo for reference, passing dynamicData between Envoy wasm filter and rbac filter is also a requirement for us, I think this proposal is very critical to implement dynamic authorization, we use proxy-wasm-cpp-sdk, but it seems that this feature is not yet integrated into the SDK. Looking forward to your reply! |
Personally, I don't have anything. But it is a work In progress and needs to be changed. |
It seems there is still intention to perform this work and the issue was auto-closed. If it can be re-opened that would be good. If someone with expertise can inform me as to what they think needs to get done next, I can try to progress this work. As far as I understand there is a concern around how to set the data, and whether it should be a serialized format. |
Commit Message: Add support for setDynamicdata (#15148)
Additional Description: This is a proposal to solve #15148
The idea is to recognize the
dynamic_metada
ed apply themThe RUST code will be something like:
Second option:
We have also a second option to solve the issue by adding another method
setDynamicdata
We already did it here the code:
The rust code is:
Please ignore the debug logs, and the code is not complete yet.
I am not an expert and before go headed I'd like to hear your opinion of which one can be the best solution or maybe none of them
Risk Level: Low
Testing: not yet
Release Notes: not yet