goauthentik / authentik

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

migration error when updating from `2021.12.5` to `2023.8` #7731

Closed imogen-ooo closed 6 months ago

imogen-ooo commented 8 months ago

Describe the bug When updating from 2021.12.5 to 2023.8

It attempts to do a db migration and then loops with an error:

KeyError: ('authentik_stages_invitation', 'invitation')

Sentry is attempting to send 2 pending events

To Reproduce Steps to reproduce the behavior:

update containers from 2021.12.5 to 2023.8 I guess with pending invites, though I don't remember those

Expected behavior I expect the db migration to take place

Logs

  Applying authentik_stages_invitation.0007_invitation_flow...�{"event": "Loaded config", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1701217951.2834759, "file": "/authentik/lib/default.yml"}
DBG event=Loaded environment variables logger=authentik.lib.config timestamp=1701217951.2841475 count=18
INF event=Starting authentik bootstrap logger=authentik.lib.config timestamp=1701217951.2843742
INF event=PostgreSQL connection successful logger=authentik.lib.config timestamp=1701217951.2947602
INF event=Redis Connection successful logger=authentik.lib.config timestamp=1701217951.2990901
INF event=Finished authentik bootstrap logger=authentik.lib.config timestamp=1701217951.299153
DBG event=Loaded config logger=authentik.lib.config timestamp=1701217951.8247201 file=/authentik/lib/default.yml
DBG event=Loaded environment variables logger=authentik.lib.config timestamp=1701217951.8254092 count=18
2023-11-29 00:32:31 [info     ] applying django migrations
2023-11-29 00:32:31 [info     ] waiting to acquire database lock
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1602547 path=authentik.admin.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1618745 path=authentik.crypto.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1629689 path=authentik.events.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1650293 path=authentik.outposts.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1691027 path=authentik.policies.reputation.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1728573 path=authentik.providers.scim.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.174817 path=authentik.sources.ldap.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.176339 path=authentik.sources.plex.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1785474 path=authentik.stages.authenticator_static.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1794035 path=authentik.stages.authenticator_totp.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1802304 path=authentik.stages.authenticator_validate.settings
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1881506 path=authentik.blueprints.settings
INF event=Booting authentik logger=authentik.lib.config timestamp=1701217953.1884706 version=2023.8.5
INF event=Enabled authentik enterprise logger=authentik.lib.config timestamp=1701217953.1903253
DBG event=Loaded app settings logger=authentik.lib.config timestamp=1701217953.1909704 path=authentik.enterprise.settings
INF event=Loaded GeoIP database last_write=1700593832 logger=authentik.events.geo pid=9 timestamp=2023-11-29T00:32:33.761439
INF event=Task published logger=authentik.root.celery pid=9 task_id=4f046587d8b04feeb87a82f87317ef28 task_name=authentik.blueprints.v1.tasks.blueprints_discovery timestamp=2023-11-29T00:32:34.737144
INF event=Task published logger=authentik.root.celery pid=9 task_id=b32bce46eca944e4a65c1f53ba5340b4 task_name=authentik.blueprints.v1.tasks.clear_failed_blueprints timestamp=2023-11-29T00:32:34.739428
Operations to perform:
  Apply all migrations: auth, authentik_blueprints, authentik_core, authentik_crypto, authentik_enterprise, authentik_events, authentik_flows, authentik_outposts, authentik_policies, authentik_policies_dummy, authentik_policies_event_matcher, authentik_policies_expiry, authentik_policies_expression, authentik_policies_password, authentik_policies_reputation, authentik_providers_ldap, authentik_providers_oauth2, authentik_providers_proxy, authentik_providers_radius, authentik_providers_saml, authentik_providers_scim, authentik_sources_ldap, authentik_sources_oauth, authentik_sources_plex, authentik_sources_saml, authentik_stages_authenticator_duo, authentik_stages_authenticator_sms, authentik_stages_authenticator_static, authentik_stages_authenticator_totp, authentik_stages_authenticator_validate, authentik_stages_authenticator_webauthn, authentik_stages_captcha, authentik_stages_consent, authentik_stages_deny, authentik_stages_dummy, authentik_stages_email, authentik_stages_identification, authentik_stages_invitation, authentik_stages_password, authentik_stages_prompt, authentik_stages_user_delete, authentik_stages_user_login, authentik_stages_user_logout, authentik_stages_user_write, authentik_tenants, contenttypes, guardian, otp_static, otp_totp, sessions
Running migrations:
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/lifecycle/migrate.py", line 95, in <module>
    execute_from_command_line(["", "migrate"])
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/migration.py", line 118, in apply
    operation.state_forwards(self.app_label, project_state)
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/operations/fields.py", line 93, in state_forwards
    state.add_field(
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/state.py", line 248, in add_field
    self.models[model_key].fields[name] = field
    ~~~~~~~~~~~^^^^^^^^^^^
KeyError: ('authentik_stages_invitation', 'invitation')
Sentry is attempting to send 2 pending events
Waiting up to 2 seconds
Press Ctrl-C to quit
  Applying authentik_stages_invitation.0007_invitation_flow...

Version and Deployment (please complete the following information):

Additional context Add any other context about the problem here.

authentik-automation[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.