-
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
Delta Bundles #1055
Comments
Another benefit to the patch approach is that it would allow us to have data loaded into OPA from different sources (e.g., kube-mgmt). It would take a bit more work to allow patching of policies but that's also possible. |
Hi @tsandall! Is this issue in progress? Is there a release date for it? |
hi @koponkin, we're not working on this currently and we have a full plate of features between now and November. If you or someone else would like to work on this, I could provide pointers. If not, we can certainly revisit this around November. |
Thanks for the update!
Will wait for this awesome feature. |
@tsandall Would be great for us to have this one. Just to add some context we have a number of services where each of them has instance of OPA. There is one service which provides bundles for all OPA's and taking into account number of instances and large amounts of data in the bundle it's very hard to scale it. We can only scale it vertically by adding more memory to fix an issue with lots of data. Delta bundles would reduce this issue a lot, so we're waiting for this feature. |
Hi @tsandall, I wonder is this under development or planned for some near time? If not, I would consider contribution to this, so would you be so kind to share "pointers" you've mentioned above. Thanks in advance! |
@tsandall Wery useful feature. It was discussed in this stream on the slack channel To add more context:
Some implementation thoughts: So, for example:
.manifest file contains:
Since the .manifest file does not contain the "roots" field, OPA will erase all the existing data and load files from the bundle. With second OPA pull request, server responds with the bundle:
.manifest file contains:
Since .manifest file contains "roots" field, data will be erased only under specified "roots". What do you think about such decision? Thanks. P.S.: I'm ready to try to work on this, so you could provide pointers. |
@ShevtsovBohdan sorry for the delayed response, not sure how I missed your update. A few thoughts.
When
The problem is that bundles are currently intended to be snapshots of state for OPA to load, i.e., they contain ALL of the policy and data that OPA should load. With multi-bundle feature you can load multiple bundles into OPA but they have to be disjoint (they can still refer to each other but they can't overlap in the data namespace.) Given that bundles are snapshots describe the full state of OPA, when a new bundle is received, OPA must erase the state from the previous bundle. It can't leave portions of the old bundle around. In the issue description, the proposal is to extend bundles to communicate more than just snapshots, i.e., they can communicate deltas. There are probably other equally viable ways of representing deltas but the design sketched out in the issue seems reasonable. One thing I'm unsure about is performance. Currently each time a bundle is downloaded and activated, OPA has to re-parse and compile the policies. This is somewhat expensive. If delta bundles are being downloaded, I would expect the simplest implementation would still re-parse and compile everything on each delta. For simplicity, perhaps we should only support deltas to JSON (not allow insert/update/remove of .rego files in delta bundles.) Question for you @ShevtsovBohdan: Do you need the ability to insert/update/remove specific .rego files in your delta bundes or would it be enough to support deltas on data.json files? If you'd like to work on this issue that would be great. @patrick-east refactored a bunch of the bundle activation code so he should probably weigh in here but I think that something like this would make sense (in order):
From an implementation/review perspective, it would be good to break these changes up into separate PRs so we can review them without getting overwhelmed. Obviously all three of the stages require test coverage (we already have a bunch of integration tests around this stuff so it should be mostly additive) and documentation. Before we move forward we should make sure the performance is going to be acceptable or we need to decide to only support patch.json files to start. |
@tsandall Thanks for the detail explanation. Now we are using one .rego file, so basically we can update it using the API. So, the answer to the question would be No, so far we don't need the ability to insert/update/remove specific .rego files in our delta bundles. Some clarification: am I understand correctly that using the approach described in the issue, we can re-use some logic from the PUT endpoint? |
Yes, the storage layer supports JSON patch-style operations on the One area that hasn't been fleshed out in the design is how this feature would interact with bundle signatures (#1757). |
Hi @tsandall Is this issue under development or in planned state? Any estimate on when this feature could land? |
@amar1728 it's not under development yet. We don't have an estimate on when it will be delivered yet. |
💭 If it's done, we can close it, can't we? |
Just to clarify in the current version of delta bundles, only changes to data are supported and not policy. We will work on delta support for policy in the future. |
I'd suggest we close this one as done and create a new ticket for policy deltas if/when we get to that. |
Closing issue as delta bundles are implemented in OPA. If there's demand to have this extended to policy later, I'd suggest we create a new issue. |
The bundle protocol is designed around polling and snapshots. As a result, bundles are not well-suited for cases that require fast propagation of policy and data changes and/or small changes to large snapshots.
To address these issues we could extend OPA and the bundle protocol to support:
By combining long-lived HTTP connections that stream bundle deltas to clients, bundle services can propagate changes to OPAs quickly and efficiently.
Example HTTP interaction
Details:
Differences from existing protocol:
Prefer: stream
HTTP headerapplication/vnd.openpolicyagent.bundles
if streaming is supported.If the client specifies
Prefer: stream
and the server does not support it, the client will fallback to polling.Delta bundles
We'll introduce a new kind of bundle that encodes a series of data patch and policy update operations. Delta bundles have the same structure and layout semantics as snapshot bundles. Differences between snapshot and delta bundles:
patch.json
files out of delta bundles.patch.json
files will contain a JSON Patch (i.e., an array of JSON objects.) The operations in the JSON Patch will be applied to OPA's in-memory store in order. The JSON Patch sets will be applied in alphabetical order (e.g.,a/b/c/patch.json
will be applied beforea/b/c/d/patch.json
.){"removed_policies": ["path/to/policy.rego"], ...}
)"revision"
value from the manifest for the If-None-Match header when executing subsequent bundle GET requests.Example Delta Bundle
patch.json:
Open Questions
The text was updated successfully, but these errors were encountered: