From cb7cd11778c8dd28956d9674e7426d633ac57abb Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Thu, 11 Jan 2024 17:00:17 +0100 Subject: [PATCH] enable django checks Signed-off-by: Marc 'risson' Schmitt --- authentik/tenants/apps.py | 10 +++++++--- lifecycle/ak | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/authentik/tenants/apps.py b/authentik/tenants/apps.py index bbb66e20a..851ae1e15 100644 --- a/authentik/tenants/apps.py +++ b/authentik/tenants/apps.py @@ -6,7 +6,7 @@ from django_tenants.utils import get_public_schema_name from authentik.blueprints.apps import ManagedAppConfig -def reconcile_default_tenant(*args, using=DEFAULT_DB_ALIAS, **kwargs): +def ensure_default_tenant(*args, using=DEFAULT_DB_ALIAS, **kwargs): """Make sure default tenant exists""" from django_tenants.utils import schema_context @@ -27,7 +27,11 @@ class AuthentikTenantsConfig(ManagedAppConfig): verbose_name = "authentik Tenants" default = True + def reconcile_global_load_checks(self): + """Load tenant checks""" + self.import_module("authentik.tenants.checks") + def reconcile_global_default_tenant(self): """Make sure default tenant exists, especially after a migration""" - post_migrate.connect(reconcile_default_tenant) - reconcile_default_tenant() + post_migrate.connect(ensure_default_tenant) + ensure_default_tenant() diff --git a/lifecycle/ak b/lifecycle/ak index 941b12594..f73d46b15 100755 --- a/lifecycle/ak +++ b/lifecycle/ak @@ -50,6 +50,10 @@ function set_mode { trap cleanup EXIT } +function run_django_checks { + python -m manage check --deploy +} + function cleanup { rm -f ${MODE_FILE} } @@ -67,6 +71,7 @@ fi if [[ "$1" == "server" ]]; then wait_for_db set_mode "server" + run_django_checks # If we have bootstrap credentials set, run bootstrap tasks outside of main server # sync, so that we can sure the first start actually has working bootstrap # credentials @@ -77,6 +82,7 @@ if [[ "$1" == "server" ]]; then elif [[ "$1" == "worker" ]]; then wait_for_db set_mode "worker" + run_django_checks check_if_root "python -m manage worker" elif [[ "$1" == "worker-status" ]]; then wait_for_db