lifecycle: revert waiting for lock, launch managed reconcile on app import
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
4edec5f666
commit
658dc63c4c
|
@ -8,3 +8,8 @@ class AuthentikManagedConfig(AppConfig):
|
||||||
name = "authentik.managed"
|
name = "authentik.managed"
|
||||||
label = "authentik_managed"
|
label = "authentik_managed"
|
||||||
verbose_name = "authentik Managed"
|
verbose_name = "authentik Managed"
|
||||||
|
|
||||||
|
def ready(self) -> None:
|
||||||
|
from authentik.managed.tasks import managed_reconcile
|
||||||
|
|
||||||
|
managed_reconcile.delay()
|
||||||
|
|
|
@ -44,11 +44,6 @@ if [[ "$1" == "server" ]]; then
|
||||||
/authentik-proxy
|
/authentik-proxy
|
||||||
elif [[ "$1" == "worker" ]]; then
|
elif [[ "$1" == "worker" ]]; then
|
||||||
wait_for_db
|
wait_for_db
|
||||||
# Check if the migration lock is set, and exit if so
|
|
||||||
# the orchestrator should restart this container, and this prevents
|
|
||||||
# errors when startup tasks are attempted to be run without
|
|
||||||
# migrations in place
|
|
||||||
python -m lifecycle.migrate check_lock
|
|
||||||
echo "worker" > $MODE_FILE
|
echo "worker" > $MODE_FILE
|
||||||
check_if_root "celery -A authentik.root.celery worker -Ofair --max-tasks-per-child=1 --autoscale 3,1 -E -B -s /tmp/celerybeat-schedule -Q authentik,authentik_scheduled,authentik_events"
|
check_if_root "celery -A authentik.root.celery worker -Ofair --max-tasks-per-child=1 --autoscale 3,1 -E -B -s /tmp/celerybeat-schedule -Q authentik,authentik_scheduled,authentik_events"
|
||||||
elif [[ "$1" == "bash" ]]; then
|
elif [[ "$1" == "bash" ]]; then
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
"""System Migration handler"""
|
"""System Migration handler"""
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
from importlib.util import module_from_spec, spec_from_file_location
|
from importlib.util import module_from_spec, spec_from_file_location
|
||||||
from inspect import getmembers, isclass
|
from inspect import getmembers, isclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -51,12 +50,6 @@ def release_lock():
|
||||||
curr.execute("SELECT pg_advisory_unlock(%s)", (ADV_LOCK_UID,))
|
curr.execute("SELECT pg_advisory_unlock(%s)", (ADV_LOCK_UID,))
|
||||||
|
|
||||||
|
|
||||||
def is_locked():
|
|
||||||
"""Check if lock is currently active (used by worker to wait for migrations)"""
|
|
||||||
curr.execute("SELECT count(*) FROM pg_locks WHERE objid = %s", (ADV_LOCK_UID,))
|
|
||||||
return curr.fetchall()[0][0]
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
conn = connect(
|
conn = connect(
|
||||||
dbname=CONFIG.y("postgresql.name"),
|
dbname=CONFIG.y("postgresql.name"),
|
||||||
|
@ -66,10 +59,6 @@ if __name__ == "__main__":
|
||||||
port=int(CONFIG.y("postgresql.port")),
|
port=int(CONFIG.y("postgresql.port")),
|
||||||
)
|
)
|
||||||
curr = conn.cursor()
|
curr = conn.cursor()
|
||||||
if len(sys.argv) > 1:
|
|
||||||
if sys.argv[1] == "check_lock":
|
|
||||||
sys.exit(is_locked())
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for migration in Path(__file__).parent.absolute().glob("system_migrations/*.py"):
|
for migration in Path(__file__).parent.absolute().glob("system_migrations/*.py"):
|
||||||
spec = spec_from_file_location("lifecycle.system_migrations", migration)
|
spec = spec_from_file_location("lifecycle.system_migrations", migration)
|
||||||
|
|
Reference in New Issue