From c7f80686de4142e0be59866cea0beae642de3623 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Wed, 2 Apr 2025 11:47:05 +0200 Subject: [PATCH] start cleanup Signed-off-by: Marc 'risson' Schmitt --- authentik/events/apps.py | 12 ------------ authentik/events/system_tasks.py | 22 ---------------------- authentik/root/settings.py | 8 ++++---- 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/authentik/events/apps.py b/authentik/events/apps.py index 915b923afc..f7b74820b4 100644 --- a/authentik/events/apps.py +++ b/authentik/events/apps.py @@ -57,18 +57,6 @@ class AuthentikEventsConfig(ManagedAppConfig): message=msg, ).save() - @ManagedAppConfig.reconcile_tenant - def prefill_tasks(self): - """Prefill tasks""" - from authentik.events.models import SystemTask - from authentik.events.system_tasks import _prefill_tasks - - for task in _prefill_tasks: - if SystemTask.objects.filter(name=task.name).exists(): - continue - task.save() - self.logger.debug("prefilled task", task_name=task.name) - @ManagedAppConfig.reconcile_tenant def run_scheduled_tasks(self): """Run schedule tasks which are behind schedule (only applies diff --git a/authentik/events/system_tasks.py b/authentik/events/system_tasks.py index dbe81853f9..946d60745e 100644 --- a/authentik/events/system_tasks.py +++ b/authentik/events/system_tasks.py @@ -132,25 +132,3 @@ class SystemTask(TenantTask): def run(self, *args, **kwargs): raise NotImplementedError - - -def prefill_task(func): - """Ensure a task's details are always in cache, so it can always be triggered via API""" - _prefill_tasks.append( - DBSystemTask( - name=func.__name__, - description=func.__doc__, - start_timestamp=now(), - finish_timestamp=now(), - status=TaskStatus.UNKNOWN, - messages=sanitize_item([_("Task has not been run yet.")]), - task_call_module=func.__module__, - task_call_func=func.__name__, - expiring=False, - duration=0, - ) - ) - return func - - -_prefill_tasks = [] diff --git a/authentik/root/settings.py b/authentik/root/settings.py index cfeb3c31d5..e997b82375 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -76,6 +76,7 @@ TENANT_APPS = [ "authentik.admin", "authentik.api", "authentik.crypto", + "authentik.events", "authentik.flows", "authentik.outposts", "authentik.policies.dummy", @@ -123,7 +124,6 @@ TENANT_APPS = [ "authentik.stages.user_login", "authentik.stages.user_logout", "authentik.stages.user_write", - "authentik.tasks.schedules", "authentik.brands", "authentik.blueprints", "guardian", @@ -500,9 +500,9 @@ try: except ImportError: pass -# Import events after other apps since it relies on tasks and other things from all apps -# being imported for @prefill_task -TENANT_APPS.append("authentik.events") +# Import schedules after other apps since it relies on tasks and ScheduledModel being +# registered for its startup. +TENANT_APPS.append("authentik.tasks.schedules") # Load subapps's settings