Skip to content

Migration fails permanently if container is killed during initial bootstrap #14201

@TJonesy

Description

@TJonesy

Describe the bug
The migration at lifecycle/system_migrations/tenant_to_brand.py fails to run and permanently crashes the authentik container(s) if the container is killed before the initial schema setup is finished but after it has been partially created.

To Reproduce
Launch new authentik instance and kill the container after one or more migrations run and before the tenant_to_brand.py migration is run.
All restarts of the container will fail and not recover.

Expected behavior
The migrations to properly handle prior partial schema completion.

Logs
Will add logs when/if I get a chance to rerun without my hack fix in place.

Version and Deployment (please complete the following information):

  • authentik version: 2025.2.4
  • Deployment: helm

Additional context
https://github.com/goauthentik/authentik/blob/19bb2de13fbbecfe50121b26b9bde482d29351ef/lifecycle/system_migrations/tenant_to_brand.py#L6C1-L6C71
Suggest change (tested by overwriting migration via configmap mount.)

ALTER TABLE authentik_tenants_tenant RENAME TO authentik_brands_brand;
Update to
ALTER TABLE IF EXISTS authentik_tenants_tenant RENAME TO authentik_brands_brand;

With this change the migration passes and everything else seems to work correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions