events: replace @prefill_task with custom base class to prefill

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-12-02 13:29:08 +01:00
parent 20c738c384
commit cf78c89830
7 changed files with 50 additions and 82 deletions

View File

@ -19,9 +19,9 @@ from structlog.stdlib import get_logger
from authentik.events.monitored_tasks import (
MonitoredTask,
PrefilledMonitoredTask,
TaskResult,
TaskResultStatus,
prefill_task,
)
from authentik.lib.utils.reflection import path_to_class
from authentik.outposts.controllers.base import BaseController, ControllerException
@ -75,9 +75,8 @@ def outpost_service_connection_state(connection_pk: Any):
cache.set(connection.state_key, state, timeout=None)
@CELERY_APP.task(bind=True, base=MonitoredTask)
@prefill_task
def outpost_service_connection_monitor(self: MonitoredTask):
@CELERY_APP.task(bind=True, base=PrefilledMonitoredTask)
def outpost_service_connection_monitor(self: PrefilledMonitoredTask):
"""Regularly check the state of Outpost Service Connections"""
connections = OutpostServiceConnection.objects.all()
for connection in connections.iterator():
@ -125,9 +124,8 @@ def outpost_controller(
self.set_status(TaskResult(TaskResultStatus.SUCCESSFUL, logs))
@CELERY_APP.task(bind=True, base=MonitoredTask)
@prefill_task
def outpost_token_ensurer(self: MonitoredTask):
@CELERY_APP.task(bind=True, base=PrefilledMonitoredTask)
def outpost_token_ensurer(self: PrefilledMonitoredTask):
"""Periodically ensure that all Outposts have valid Service Accounts
and Tokens"""
all_outposts = Outpost.objects.all()