From 21efee8f44469865645a8f11e0109dd6e8dcec1b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 12 Feb 2022 18:40:21 +0100 Subject: [PATCH] admin: add additional logging when restarting a task Signed-off-by: Jens Langhammer --- authentik/admin/api/tasks.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/authentik/admin/api/tasks.py b/authentik/admin/api/tasks.py index ad54c9b50..dc2d73a66 100644 --- a/authentik/admin/api/tasks.py +++ b/authentik/admin/api/tasks.py @@ -12,10 +12,13 @@ from rest_framework.permissions import IsAdminUser from rest_framework.request import Request from rest_framework.response import Response from rest_framework.viewsets import ViewSet +from structlog.stdlib import get_logger from authentik.core.api.utils import PassiveSerializer from authentik.events.monitored_tasks import TaskInfo, TaskResultStatus +LOGGER = get_logger() + class TaskSerializer(PassiveSerializer): """Serialize TaskInfo and TaskResult""" @@ -89,6 +92,7 @@ class TaskViewSet(ViewSet): try: task_module = import_module(task.task_call_module) task_func = getattr(task_module, task.task_call_func) + LOGGER.debug("Running task", task=task_func) task_func.delay(*task.task_call_args, **task.task_call_kwargs) messages.success( self.request, @@ -96,6 +100,7 @@ class TaskViewSet(ViewSet): ) return Response(status=204) except (ImportError, AttributeError): # pragma: no cover + LOGGER.warning("Failed to run task, remove state", task=task) # if we get an import error, the module path has probably changed task.delete() return Response(status=500)