-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
question: suggestion on effecting changes in external system #4209
Comments
Hi Peter! That's a peculiar use case 😃 My first thought was that the caller (i.e. the client) would be the right place to collect the result and persist it elsewhere.. but I take it you have considered that already and dismissed the idea? How fast are these requests expected to come in? I mean, would request #2 come just milliseconds after request #1, or how much time do you have to process the first decision? I could imagine building a custom service to process decision logs, parse out whatever data is of interest and then feed that back into a bundle or via OPA's REST API... but it would obviously not be instantaneous. I think we can exclude using |
Hi Anders, thanks for your reply!
I would think to decouple the persisting responsibility from the client(requester), and move it to the whole decision making service as a whole considering historical data is the context for the evaluation, that being said, if it has to be done in this way, I will have a proxy service takes care of this to decouple it from the original client. :)
This is a good question! I haven't considered the "race" condition, considering similar requests usually do not happen that frequently(milliseconds).
As eventually historical data will become large, they will be persisted in a remote storage(DB or NoSQL) and probably not suite in the bundle(and also considering the freshness), an evaluation could take milliseconds or less than a second, but it's acceptable. So.. say if the persist is wrapped into a built-in function, which seems to be more intuitive, as it's part of the evaluation process, and user can see how it is done as a whole by looking at the rego file, is there a way to guarantee the call will not be omitted by OPA? |
OPA is, like you said, responsible for the decision making. It is however not responsible for enforcement, or any other type of side effect that may be produced as a result of its decisions. Moving that responsibility into OPA is not decoupling (from an OPA POV) — it's introducing it.
If that's so, I'd suggest using
From OPA's perspective, this isn't intuitive at all. Again I think you're conflating the "evaluation process" with enforcement and side effects. OPA is built entirely with the assumption that isn't handled in policy.
Sure, I don't think it'll get omitted if it's in a path required for the policy decision. |
I think you are making valid points, querying data is part of the evaluation, but persist is actually not. Thanks for your time! |
OPA is really great!
I started evaluating OPA recently and I would like to ask for some suggestions on how to make changes in external system during a policy execution phase. As per the doc, both
http.send
and custom built-in functions are mentioned not to be guaranteed to be executed. In my case, the decision making depends on historical data, for example, when a request is allowed, I would like to persist the request along with some additional data in a DB, and such historical data will be fetched from remote to evaluate the next request. Some workaround that I can think ofand both have to follow the contract that a specific field in the result states whether and what to be persisted.
Not sure what is right way of doing so, any suggestion is appreciated. Thanks.
The text was updated successfully, but these errors were encountered: