From e211604860b1f051229839e92d77a46815f5a3ee Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Thu, 12 Jun 2025 16:00:56 +0200 Subject: [PATCH] implement send_on_startup Signed-off-by: Marc 'risson' Schmitt --- authentik/blueprints/apps.py | 4 ++-- authentik/outposts/apps.py | 2 +- authentik/tasks/schedules/apps.py | 5 +++++ authentik/tasks/schedules/lib.py | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/authentik/blueprints/apps.py b/authentik/blueprints/apps.py index e4ed92fa99..7d904c93aa 100644 --- a/authentik/blueprints/apps.py +++ b/authentik/blueprints/apps.py @@ -147,11 +147,11 @@ class AuthentikBlueprintsConfig(ManagedAppConfig): ScheduleSpec( actor=blueprints_discovery, crontab=f"{fqdn_rand('blueprints_v1_discover')} * * * *", - run_on_startup=True, + send_on_startup=True, ), ScheduleSpec( actor=clear_failed_blueprints, crontab=f"{fqdn_rand('blueprints_v1_cleanup')} * * * *", - run_on_startup=True, + send_on_startup=True, ), ] diff --git a/authentik/outposts/apps.py b/authentik/outposts/apps.py index 10839cd8c1..632076569b 100644 --- a/authentik/outposts/apps.py +++ b/authentik/outposts/apps.py @@ -82,7 +82,7 @@ class AuthentikOutpostConfig(ManagedAppConfig): ScheduleSpec( actor=outpost_connection_discovery, crontab=f"{fqdn_rand('outpost_connection_discovery')} */8 * * *", - run_on_startup=True, + send_on_startup=True, paused=not CONFIG.get_bool("outposts.discover"), ), ] diff --git a/authentik/tasks/schedules/apps.py b/authentik/tasks/schedules/apps.py index 32f38c20b3..f15c9e856d 100644 --- a/authentik/tasks/schedules/apps.py +++ b/authentik/tasks/schedules/apps.py @@ -26,12 +26,17 @@ class AuthentikTasksSchedulesConfig(ManagedAppConfig): from authentik.tasks.schedules.models import Schedule + schedules_to_send = [] with transaction.atomic(): pks_to_keep = [] for spec in specs: schedule = spec.update_or_create() pks_to_keep.append(schedule.pk) + if spec.send_on_startup: + schedules_to_send.append(schedule) Schedule.objects.exclude(pk__in=pks_to_keep).delete() + for schedule in schedules_to_send: + schedule.send() @ManagedAppConfig.reconcile_tenant def reconcile_tenant_schedules(self): diff --git a/authentik/tasks/schedules/lib.py b/authentik/tasks/schedules/lib.py index 62fe9e84b8..88d8460829 100644 --- a/authentik/tasks/schedules/lib.py +++ b/authentik/tasks/schedules/lib.py @@ -26,7 +26,7 @@ class ScheduleSpec: send_on_save: bool = False - run_on_startup: bool = False + send_on_startup: bool = False def get_uid(self) -> str: if self.uid is not None: