This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2021-02-03 20:18:31 +00:00
|
|
|
"""managed tasks"""
|
|
|
|
from django.db import DatabaseError
|
|
|
|
|
|
|
|
from authentik.core.tasks import CELERY_APP
|
2021-12-09 09:18:00 +00:00
|
|
|
from authentik.events.monitored_tasks import (
|
|
|
|
MonitoredTask,
|
|
|
|
TaskResult,
|
|
|
|
TaskResultStatus,
|
|
|
|
prefill_task,
|
|
|
|
)
|
2021-02-03 20:18:31 +00:00
|
|
|
from authentik.managed.manager import ObjectManager
|
|
|
|
|
|
|
|
|
2021-12-09 09:18:00 +00:00
|
|
|
@CELERY_APP.task(bind=True, base=MonitoredTask)
|
|
|
|
@prefill_task
|
|
|
|
def managed_reconcile(self: MonitoredTask):
|
2021-02-03 20:18:31 +00:00
|
|
|
"""Run ObjectManager to ensure objects are up-to-date"""
|
|
|
|
try:
|
|
|
|
ObjectManager().run()
|
|
|
|
self.set_status(
|
2021-08-03 15:45:16 +00:00
|
|
|
TaskResult(TaskResultStatus.SUCCESSFUL, ["Successfully updated managed models."])
|
2021-02-03 20:18:31 +00:00
|
|
|
)
|
2021-11-15 18:53:08 +00:00
|
|
|
except DatabaseError as exc: # pragma: no cover
|
2021-02-03 20:18:31 +00:00
|
|
|
self.set_status(TaskResult(TaskResultStatus.WARNING, [str(exc)]))
|