-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
update API object when configuration changes #1636
Comments
Some considerations on this: The config is read in the global scope in e.g. If there's only one worker process (with possibly threads), it would be possible to change the config in place by doing something like To update all workers, a graceful restart is necessary and in gunicorn can be done by using Other possibilities are to read the config on reach request, which would be really slow. We could also cache it for e.g. 1 minute in each worker or even read it from some hot cache like redis (probably overkill). |
You can use the gunicon reload function to perform this as described here: https://docs.pygeoapi.io/en/latest/admin-api.html#pygeoapi-hot-reloading-in-gunicorn. The docker example for pygeoapi admin implements this strategy in the entrypoint, as does the entrypoint in wis2box-api. There is a security concern for users who do not want to update their configuration which is why it is not in the default Docker image of pygeoapi. If it is their wish to not update the configuration, i.e. the Admin API is not enabled, I do not think pygeoapi should hot-reload changes made to the configuration. I am partial to some solution that exists below the (Flask, Starlette, Django) framework to avoid all these potential deployment variations. |
Maybe it could be an option to consider a database-driven configuration (at least for the resources)? I described something similar a while ago in a feature request (#1351). Restarting/hot-reloading seems like a workaround to me. I do not see an issue in performance when introducing a lightweight database. This would solve the thread issues as well. |
Another note, anytime the configuration gets updated, the Open API document must also be recreated and read into memory. Considerations need to be taken for both |
This Issue has been inactive for 90 days. As per RFC4, in order to manage maintenance burden, it will be automatically closed in 7 days. |
@tomkralidis please confirm this is still ongoing |
There is a related PR. I did not test it yet but from looking at the changes it seems to not update the OpenAPI (I might be wrong, @Alex-NRCan). |
Thanks for hooking me into this issue @matthesrieke . I've read the comments in this thread. What I could add on to the discussion is that my PR:
As for the OpenAPI spec, that needed to be refreshed on every collection that was added/removed on the fly, yes, that was a tricky one. In our case, we ended up creating a 'generic' openapi spec yaml. So, instead of having 1 "paragraph" per collection, we have 1 generic paragraph with the *Note: It does have the caveat that we had to consider a user error message handling when one tries to hit a /coverage endpoint on a feature type collection for example. We thought about this and, for our case, we still prefer to have a generic OpenAPI spec, for these reasons:
|
@Alex-NRCan really interesting, and reasonable decisions on the OpenAPI part. I generally support the approach of a generic document (as you said, loading times, complexity, ...), but am wondering if there are use cases where an explicit OpenAPI with all collections is required. @tomkralidis @webb-ben thoughts? |
Description
Ensure that changes to the configuration are visible without requiring a service restart.
Steps to Reproduce
Expected behavior
pygeoapi always provides service based on the latest configuration changes
Screenshots/Tracebacks
Environment
Additional context
cc @totycro
The text was updated successfully, but these errors were encountered: