implement send_on_startup

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt
2025-06-12 16:00:56 +02:00
parent 7ed711e8f0
commit e211604860
4 changed files with 9 additions and 4 deletions

View File

@ -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,
),
]

View File

@ -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"),
),
]

View File

@ -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):

View File

@ -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: