Repository navigation
root: handle SIGHUP and SIGUSR2, healthcheck gunicorn - #6630
Conversation
This is the first step to handle configuration reloading. With those changes, it is already possible to do so, by sending a SIGUSR2 signal to the Go server process. The next step would be to watch for changes to configuration files and call the Restart function of the GoUnicorn instance. SIGHUP is catched by the go server and forwarded as-is to gunicorn, which causes it to restart its workers. However, that does not trigger a reload of the Django settings, probably because they are already loaded in the master, before creating any of the worker instances. SIGUSR2, however, can be used to spawn a new gunicorn master process, but handling it is a bit trickier. Please refer to Gunicorn's documentation[0] for details, especially the "Upgrading to a new binary on the fly" section. As we are now effectively killing the gunicorn processed launched by the server, we need to handle some sort of check to make sure it is still running. That's done by using the already existing healthchecks, making them useful not only for the application start, but also for its lifetime. If a check is failed too many times in a given time period, the gunicorn processed is killed (if necessary) and then restarted. [0] https://docs.gunicorn.org/en/20.1.0/signals.html Other relevant links and documentation: Python library handling the processing swaping upon a SIGUSR2: https://github.com/flupke/rainbow-saddle/ Golang cannot easily check if a process exists on Unix systems: golang/go#34396 Signed-off-by: Marc 'risson' Schmitt <[email protected]>
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
| started: false, | ||
| killed: false, | ||
| alive: false, |
There was a problem hiding this comment.
Would an enum be better here?
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6630 +/- ##
=======================================
Coverage 92.71% 92.71%
=======================================
Files 567 567
Lines 27965 27965
=======================================
Hits 25925 25925
Misses 2040 2040
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-gunicorn-health-1695814484-a310649
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sFor arm64, use these values: AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-gunicorn-health-1695814484-a310649-arm64
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-gunicorn-health-1695814484-a310649For arm64, use these values: authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-gunicorn-health-1695814484-a310649-arm64Afterwards, run the upgrade commands from the latest release notes. |
BeryJu
left a comment
There was a problem hiding this comment.
I'd like to give this some more testing in dogfooding before we actually ship it, let's merge it after 2023.8 is out
|
I'll convert to draft to prevent accidental merging. |
5b36dea to
5f3e008
Compare
Signed-off-by: Jens Langhammer <[email protected]> # Conflicts: # cmd/server/server.go # internal/gounicorn/gounicorn.go
5f3e008 to
eee8024
Compare
Signed-off-by: Jens Langhammer <[email protected]>
✅ Deploy Preview for authentik ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
LGTM |
* main: (41 commits) root: fix missing /lifecycle in path website/blog: add info-block to blog about m2m (#7002) root: handle SIGHUP and SIGUSR2, healthcheck gunicorn (#6630) flows: stage_invalid() makes flow restart depending on invalid_response_action setting (#6780) core: bump psycopg from 3.1.11 to 3.1.12 (#6997) core: bump pydantic from 2.4.0 to 2.4.1 (#6998) web: bump the sentry group in /web with 2 updates (#6999) web: bump pyright from 1.1.328 to 1.1.329 in /web (#7000) website/blog: improved sentence (#6995) website/blog: fix missing link in m2m post (#6994) web/user: fix incorrect link to admin interface (#6993) root: disable APPEND_SLASH (#6928) root: replace boj/redistore with vendored version of rbcervilla/redisstore (#6988) sources/ldap: add default property mapping to mirror directory structure (#6990) website/blogs: Blog about m2m (#6974) root: make Celery worker concurrency configurable (#6837) root: make postgres connection in makefile customizable (#6977) core: prevent self-impersonation (#6885) web: bump @typescript-eslint/parser from 6.7.2 to 6.7.3 in /web (#6984) core: bump pydantic from 2.3.0 to 2.4.0 (#6979) ...
* main: (50 commits) web/admin: invitation stage: default "continue without invitation" to false core: bump pydantic from 2.4.1 to 2.4.2 (#7014) website: bump postcss from 8.4.30 to 8.4.31 in /website (#7015) internal: fix redis session store (#7011) web: bump rollup from 3.29.3 to 3.29.4 in /web (#7009) core: bump github.com/prometheus/client_golang from 1.16.0 to 1.17.0 (#7007) web: bump the esbuild group in /web with 2 updates (#7005) website: bump react-tooltip from 5.21.4 to 5.21.5 in /website (#7006) core: bump github.com/redis/go-redis/v9 from 9.2.0 to 9.2.1 (#7008) root: fix missing /lifecycle in path website/blog: add info-block to blog about m2m (#7002) root: handle SIGHUP and SIGUSR2, healthcheck gunicorn (#6630) flows: stage_invalid() makes flow restart depending on invalid_response_action setting (#6780) core: bump psycopg from 3.1.11 to 3.1.12 (#6997) core: bump pydantic from 2.4.0 to 2.4.1 (#6998) web: bump the sentry group in /web with 2 updates (#6999) web: bump pyright from 1.1.328 to 1.1.329 in /web (#7000) website/blog: improved sentence (#6995) website/blog: fix missing link in m2m post (#6994) web/user: fix incorrect link to admin interface (#6993) ...

Details
Extracted from #5415
Checklist
ak test authentik/)make lint-fix)If an API change has been made
make gen-build)If changes to the frontend have been made
make web)make i18n-extract)If applicable
make website)