From 06850a2f57730aaa6918d772818d211bcd44cd9a Mon Sep 17 00:00:00 2001 From: Alissa Gerhard Date: Fri, 8 Sep 2023 20:37:54 +0200 Subject: [PATCH] sources/ldap: fix task timeout for ldap_sync_all and ldap_sync_single (#6809) * sources/ldap: fix task timeout for ldap_sync_all and ldap_sync_single * ldap_sync_all runs tasks async so doesn't need longer timeouts Signed-off-by: Jens Langhammer * bump time more as we run some tasks in serial and add more leeway Signed-off-by: Jens Langhammer --------- Signed-off-by: Jens Langhammer Co-authored-by: Jens Langhammer --- authentik/sources/ldap/tasks.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/authentik/sources/ldap/tasks.py b/authentik/sources/ldap/tasks.py index 39aeb4c3c..0223a68ba 100644 --- a/authentik/sources/ldap/tasks.py +++ b/authentik/sources/ldap/tasks.py @@ -33,7 +33,13 @@ def ldap_sync_all(): ldap_sync_single(source.pk) -@CELERY_APP.task() +@CELERY_APP.task( + # We take the configured hours timeout time by 2.5 as we run user and + # group in parallel and then membership, so 2x is to cover the serial tasks, + # and 0.5x on top of that to give some more leeway + soft_time_limit=(60 * 60 * CONFIG.get_int("ldap.task_timeout_hours")) * 2.5, + task_time_limit=(60 * 60 * CONFIG.get_int("ldap.task_timeout_hours")) * 2.5, +) def ldap_sync_single(source_pk: str): """Sync a single source""" source: LDAPSource = LDAPSource.objects.filter(pk=source_pk).first()