Skip to content
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

API to tell OPA to download a new bundle #1336

Open
spellr opened this issue Apr 14, 2019 · 20 comments
Open

API to tell OPA to download a new bundle #1336

spellr opened this issue Apr 14, 2019 · 20 comments

Comments

@spellr
Copy link

spellr commented Apr 14, 2019

Right now, when changing a bundle, we need to wait for all OPAs to download the new bundle periodically, and update their policies. This can raise security issues, and also make neighboring OPAs to have conflicting states/decisions.

A possible work-around can be shortening the download frequency, but that can create constant load on the bundle server.

It would be great to have an API endpoint in OPA to tell it, "update now".
This way, when a new policy is added to the bundle, we can tell all OPAs to download the new bundle.

@srenatus
Copy link
Contributor

I suppose there's alternatives serving the same goal? I.e., some kind of subscription mechanism for bundle downloading? (like using long polling, websockets, sse, ... whatever's appropriate)

@tsandall
Copy link
Member

Like @srenatus mentions, this is somewhat related to #1055.

One option would be to extend the OPA API to include a bundle resource.

POST /v1/bundles/<name>/sync    # trigger bundle synchronization

I could imagine it being useful to have an API that returns the bundle status (activated, errors, timestamps, etc.)

GET /v1/bundles/<name>          # return specific bundle status
GET /v1/bundles                 # return list of bundle status

@timothyhinrichs WDYT?

@Devlin556
Copy link

+1, very important feature.It really needed.

@WellFail
Copy link

+1

@kolyasya
Copy link

+1 please add asap

@tsandall
Copy link
Member

I'm hesitant to go ahead and implement this when it overlaps heavily with #1055. Curious what @timothyhinrichs and @koponen-styra have to say.

@koponen-styra
Copy link
Contributor

koponen-styra commented May 29, 2019

Accelerating the download with an explicit signal from outside sounds good to me! I have no strong opinions about the involved API change(s), though.

@timothyhinrichs
Copy link
Member

timothyhinrichs commented May 29, 2019 via email

@gujun4990
Copy link
Contributor

Currently, @ashutosh-narkar have realized the long polling(#3418).

@stale
Copy link

stale bot commented Nov 22, 2021

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.

@stale stale bot added the inactive label Nov 22, 2021
@multigrid101
Copy link

Hello all, was this ever implemented? I can can see config variables for this in the docs (e.g. bundles[_].trigger = manual) but no info on how to actually execute the manual trigger.

@anderseknert
Copy link
Member

anderseknert commented Feb 7, 2023

@multigrid101 no, the issue is still open :) The manual trigger you're refering to is a feature of the Go SDK, which I believe was contributed for the purpose of running OPA in AWS Lambdas, where periodic polling is undesirable. It's not currently exposed via the HTTP API.

The long polling feature is another option for telling OPA about updates to bundles.

@renatosc
Copy link
Contributor

I second this. The "Delta Bundle" #1055 doesn't support policy change, only data update. Having a API that forces the OPA to download the bundle right away would be great.

@anderseknert
Copy link
Member

@renatosc long polling (see my previous comment) works for any type of bundles, if that's an option for you.

@renatosc
Copy link
Contributor

renatosc commented Mar 15, 2023

@anderseknert , yes we have short and long pooling but on either options you are "overloading" the server (via multiple requests or by keeping a connection open). If you already have a system working on a subscription based model that receive events, having to leave another connection open is a waste of resource.

I don't mind forking and submitting a PR for the change.

@charlieegan3
Copy link
Contributor

on either options you are overloading the server

Out of interest, is your server setting Etag headers in responses when downloading bundles?

@stale stale bot removed the inactive label Mar 15, 2023
@renatosc
Copy link
Contributor

Hi @charlieegan3, we do not have implemented it yet. When I said "we have" it was referring to that I know we have the options of using short/long pooling with OPA right now. Our system will have a SignalR connection to receive events such as OPA needs to update its bundle. So having OPA using short/long polling would be unnecessary if we had a way to trigger the bundle sync/refresh as suggested by this issue.

@charlieegan3
Copy link
Contributor

My concern in your scenario @renatosc is that by triggering reloading of bundles via an API would create a Thundering Herd Problem when many OPAs update at the same time. This might be even more problematic if you're concerned about your bundle server load.

While I can see some value in adding this endpoint for testing purposes, I remain unconvinced that it's a good pattern for most production use cases or achieving consistency in loaded bundle state of many OPA instances. Oftentimes, new OPA instances can start at any moment - either as sidecars or from an horizontal scaling event.

If we do add this feature, I think it'd be good to document that relying on it would be a step away from a level based system which is often a desirable property.

@ashutosh-narkar
Copy link
Member

@renatosc FWIW there are currently two ways to control how a bundle is downloaded from the remote server. The default is periodic wherein OPA periodically downloads a bundle. And there is the manual mode where you can manually trigger the bundle download. This feature is exposed via OPA's GO API atm.

@stale
Copy link

stale bot commented Apr 17, 2023

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.

@stale stale bot added the inactive label Apr 17, 2023
charlieegan3 added a commit to charlieegan3/opa that referenced this issue Dec 7, 2023
This option is only available when using OPA from go and not in the
server.

Context: open-policy-agent#1336

Signed-off-by: Charlie Egan <charlie@styra.com>
anderseknert pushed a commit that referenced this issue Dec 7, 2023
This option is only available when using OPA from go and not in the
server.

Context: #1336

Signed-off-by: Charlie Egan <charlie@styra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests