Skip to content

runtime: Restart the serve routine to apply config file changes - #9203

Open
sspaink wants to merge 3 commits into
open-policy-agent:mainfrom
sspaink:config-reload-restart
Open

sspaink wants to merge 3 commits into
open-policy-agent:mainfrom
sspaink:config-reload-restart

Conversation

@sspaink

@sspaink sspaink commented Sep 14, 2026

Copy link
Copy Markdown
Member

Follow up to: #9192 (comment)

Following a good suggestion from @charlieegan3, instead of trying to reload configuration in place restarting the server gives us a way to update everything without having to document a list of settings that don't work. If necessary we can revisit this in the future and make it more of a hybrid solution if there is a demand for it.

@netlify

netlify Bot commented Sep 14, 2026

Copy link
Copy Markdown

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit b1fd730
🔍 Latest deploy log https://app.netlify.com/projects/openpolicyagent/deploys/6aac058161f7cb0008a19084
😎 Deploy Preview https://deploy-preview-9203--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sspaink
sspaink force-pushed the config-reload-restart branch from 32b73e0 to 1f06457 Compare September 14, 2026 17:07
@sspaink
sspaink marked this pull request as draft September 14, 2026 19:13
@anderseknert

Copy link
Copy Markdown
Member

Is a stateful disk-based watch approach like this not something of a cloud native anti-pattern? 🤔
I guess we have enough type of deployments out in the wild to motivate more esoteric configurations, and for development and testing this could certainly be helpful. I think being at least a little more opinionated in the docs and explain the pros, cons and purpose of each approach would go a long way, as docs otherwise tend to be interpreted unconditionally as "100% recommended and supported". Given past issues we've seen with e.g. disk watchers and networked file systems and whatnot — issues that have often been environment specific, intermittent and close to impossible for us to reproduce — I'd try to at least throw in a disclaimer or two 😅

(And apologies if this has all been covered in previous discussions. As you know I've not been able to follow everything that's been going on recently).

@sspaink
sspaink force-pushed the config-reload-restart branch 2 times, most recently from 1b47102 to 567315f Compare September 14, 2026 22:25
@sspaink

sspaink commented Sep 14, 2026

Copy link
Copy Markdown
Member Author

@anderseknert no worries I don't think this has been covered in previous discussions yet, so good to ask now!

I don't think it is an anti-pattern, I think this is similar to how Kubernetes ConfigMaps can be updated live. CoreDNS also lets configs be updated automatically. Prometheus has something similar but needs a trigger. I do agree better documentation is needed to be very explicit about the pros and cons. @charlieegan3 also mentioned maybe adding a new flag or something similar to make this reload behavior opt-in. Which could also help us be more opinionated and let users make the right choice, in case I am wrong and this is an anti-pattern 😅

Would a new flag like --watch-config be ok? Better decide on this before the release while it's easy to change.

@johanfylling, @philipaconrad or @srenatus more input on this would be great 👀 in case this needs more design review.

@anderseknert

Copy link
Copy Markdown
Member

I don't think it is an anti-pattern, I think this is similar to how Kubernetes ConfigMaps can be updated live.

Right, that's kinda the point I was trying/failed to make. Managing lifetimes and state is the role of Kubernetes in that type of deployment. If you want to run something scheduled you shouldn't configure cron jobs in your container distros, but use Kubernetes jobs and scheduling. Same with health checks, orchestration, metrics, whatnot. Having OPA itself decide to shutdown/restart triggered by some opaque (seen from the outside) event seems to me like it would go against that. But to also reiterate, I'm not necessarily opposed :) OPA runs on Windows monoliths, mainframes, in cars and what have you. If we need to better support a use-case where this would help, we should do it. Just trying to make sure we're clear about when to use what, and when not to. Making this explicit / opt-in sounds reasonable to me.

@sspaink
sspaink force-pushed the config-reload-restart branch from 12f538e to 6223580 Compare September 15, 2026 14:06
@sspaink
sspaink marked this pull request as ready for review September 15, 2026 14:24
@sspaink

sspaink commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Thank you @anderseknert for the explanation, that makes sense. I've pushed an update to have this be opt-in using a new flag --watch-config.

@srenatus

Copy link
Copy Markdown
Contributor

I agree it's most likely not the pure gospel of immutable infrastructure. That said, if OPA is a sidecar and you can only restart the entire pod, it might be nice to have a compromise available.

Since it's a niche thing, the simpler the approach, the better. This looks good to me. What will happen to existing connections? Presumably they'll be dropped, but that's probably OK.

The configuration file watcher needs to parse every plugin section to
check a new configuration before restarting under it, and that logic
only existed inside discovery.

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
Both registered a commit trigger and never took it back off, and Manager.Stop
closed a store it does not own, so swapping either one over a live store left
a trigger behind pointing at the old instance and closed the store underneath
the new one.

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
Reconfiguring in place could only reach part of the configuration, so the rest
was refused and the docs needed a table of what OPA would not do. A restart
reaches all of it: the file is validated first, then the server and the plugins
are rebuilt from it over the store that outlives them, behind an opt-in
--watch-config flag since a restart costs far more than --watch's reload.

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
@sspaink
sspaink force-pushed the config-reload-restart branch from 6223580 to b1fd730 Compare September 17, 2026 15:21
@sspaink

sspaink commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

So idle connections get closed, waits for in-progress requests to finish, new connections are refused, and then any long running requests never stop running. So no in-progress request is dropped.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants