You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently puppetboard tries to connect to puppetdb as a side-effect of importing puppetboard.app and calls sys.exit() if that (or the version check) fails. It also configures logging (six times). Both is unusual, as imports should not have such side-effects. This may cause some issues:
Puppetboard will fail (hard) if puppetdb is not ready yet, resulting in lots of unnecessary container or service restarts and lots of log noise during startup. Once the app is running, puppetdb can go down and errors are properly handled. It is just the initial check that may cause a hard error.
Puppetboard overrides logging configuration done by the actual entry point (e.g. a custom wsgi.py that imports puppetboard).
Puppetboard cannot be embedded into another WSGI application or wrapped with middleware easily, because importing puppetboard.app may trigger sys.exit() as a side-effect.
Proposal:
Only do uncritical stuff at import-time (e.g. importing all the puppetboard.views or configuring jinja2) so import app from puppetboard.app does not crash the process but still returns a fully populated app object.
Move logging configuration and checks into a new puppetboard.app::bootstrap(checks=True, logging=True) function that simply returns the app object and can be used by gunicorn for initialization.
Bonus points if configuration can be passed in as a dict (instead of the implicit and hard-coded dependency on os.environ)
Some background: I'm working on a project that provides teams with a convenient web UI to manage a puppet-server (e.g. deploy environments from git, sign certs, encrypt secrets, ...). This web app also has a puppetboard embedded in it, which is protected by the same auth framework (OpenID+RBAC) as the rest of the application. I had to jump through a bunch of hoops to get this to work, but it works.
The text was updated successfully, but these errors were encountered:
Currently puppetboard tries to connect to puppetdb as a side-effect of importing
puppetboard.app
and callssys.exit()
if that (or the version check) fails. It also configures logging (six times). Both is unusual, as imports should not have such side-effects. This may cause some issues:wsgi.py
that imports puppetboard).puppetboard.app
may triggersys.exit()
as a side-effect.Proposal:
puppetboard.views
or configuring jinja2) soimport app from puppetboard.app
does not crash the process but still returns a fully populated app object.puppetboard.app::bootstrap(checks=True, logging=True)
function that simply returns the app object and can be used by gunicorn for initialization.os.environ
)Some background: I'm working on a project that provides teams with a convenient web UI to manage a puppet-server (e.g. deploy environments from git, sign certs, encrypt secrets, ...). This web app also has a puppetboard embedded in it, which is protected by the same auth framework (OpenID+RBAC) as the rest of the application. I had to jump through a bunch of hoops to get this to work, but it works.
The text was updated successfully, but these errors were encountered: