goauthentik / authentik

The authentication glue you need.
https://goauthentik.io
Other
13.28k stars 887 forks source link

The authentik server fails to start due to an error while migrating #11251

Closed IcarusCoding closed 1 month ago

IcarusCoding commented 1 month ago

Describe the bug During the migration process, an error occurs due to a missing module ('daphne'). This causes the system to fail with a ModuleNotFoundError, leading to the inability to start the authentik server.

Expected behavior The system should run the migration without errors and proceed with successfully starting the authentik server.

Logs

Compose Logs ``` DBG event=Loaded config logger=authentik.lib.config timestamp=1725618880.8508332 file=/authentik/lib/default.yml DBG event=Loaded environment variables logger=authentik.lib.config timestamp=1725618880.8517714 count=7 INF event=Starting authentik bootstrap logger=authentik.lib.config timestamp=1725618882.4421377 INF event=PostgreSQL connection successful logger=authentik.lib.config timestamp=1725618882.476584 INF event=Redis Connection successful logger=authentik.lib.config timestamp=1725618882.480361 INF event=Finished authentik bootstrap logger=authentik.lib.config timestamp=1725618882.4808307 2024-09-06 10:34:42 [info ] waiting to acquire database lock 2024-09-06 10:34:42 [info ] applying django migrations INF event=Booting authentik logger=authentik.lib.config timestamp=1725618886.7241907 version=2024.8.0 INF event=Enabled authentik enterprise logger=authentik.lib.config timestamp=1725618886.7314208 DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7345145 path=authentik.enterprise.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7441187 path=authentik.admin.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7486737 path=authentik.events.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7506618 path=authentik.stages.authenticator_totp.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7561266 path=authentik.sources.oauth.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7590857 path=authentik.enterprise.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7617524 path=authentik.sources.plex.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7680025 path=authentik.blueprints.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7733126 path=authentik.outposts.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7773035 path=authentik.stages.authenticator_webauthn.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7794209 path=authentik.crypto.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.783644 path=authentik.enterprise.providers.google_workspace.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7875857 path=authentik.sources.ldap.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7916334 path=authentik.providers.scim.settings DBG event=Loaded app settings logger=authentik.lib.config timestamp=1725618886.7942739 path=authentik.enterprise.providers.microsoft_entra.settings Traceback (most recent call last): File "/lifecycle/migrate.py", line 112, in run_migrations execute_from_command_line(["", "migrate_schemas"]) File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line utility.execute() File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 416, in execute django.setup() File "/ak-root/venv/lib/python3.12/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/ak-root/venv/lib/python3.12/site-packages/django/apps/registry.py", line 91, in populate app_config = AppConfig.create(entry) ^^^^^^^^^^^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/django/apps/config.py", line 193, in create import_module(entry) File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1324, in _find_and_load_unlocked ModuleNotFoundError: No module named 'daphne' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "//./manage.py", line 43, in run_migrations() File "/lifecycle/migrate.py", line 118, in run_migrations release_lock(curr) File "/lifecycle/migrate.py", line 67, in release_lock LOGGER.info("releasing database lock") File "/ak-root/venv/lib/python3.12/site-packages/structlog/_native.py", line 134, in meth return self._proxy_to_logger(name, event, **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/structlog/_base.py", line 214, in _proxy_to_logger args, kw = self._process_event(method_name, event, event_kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/structlog/_base.py", line 165, in _process_event event_dict = proc(self._logger, method_name, event_dict) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/authentik/lib/logging.py", line 125, in add_tenant_information tenant = getattr(connection, "tenant", None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/django/utils/connection.py", line 15, in __getattr__ return getattr(self._connections[self._alias], item) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/django/utils/connection.py", line 62, in __getitem__ conn = self.create_connection(alias) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/django/db/utils.py", line 193, in create_connection backend = load_backend(db["ENGINE"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/django/db/utils.py", line 113, in load_backend return import_module("%s.base" % backend_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/authentik/root/db/base.py", line 3, in from django_tenants.postgresql_backend.base import DatabaseWrapper as BaseDatabaseWrapper File "/ak-root/venv/lib/python3.12/site-packages/django_tenants/postgresql_backend/base.py", line 10, in from django.contrib.contenttypes.models import ContentType File "/ak-root/venv/lib/python3.12/site-packages/django/contrib/contenttypes/models.py", line 139, in class ContentType(models.Model): File "/ak-root/venv/lib/python3.12/site-packages/django/db/models/base.py", line 129, in __new__ app_config = apps.get_containing_app_config(module) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/django/apps/registry.py", line 260, in get_containing_app_config self.check_apps_ready() File "/ak-root/venv/lib/python3.12/site-packages/django/apps/registry.py", line 138, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. timestamp="2024-09-06T10:34:47Z" level=warning event="gunicorn process died, restarting" error="exit status 1" logger=authentik.router timestamp="2024-09-06T10:34:47Z" level=error event="gunicorn failed to start, restarting" error="exit status 1" logger=authentik.router ```

Version and Deployment

Additional context The authentik worker starts without any problems.

IcarusCoding commented 1 month ago

Fixed: my postgres image was corrupted.