implement send_on_startup
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
@ -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,
|
||||
),
|
||||
]
|
||||
|
@ -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"),
|
||||
),
|
||||
]
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user