From 4282cc653c1a95beee962dbdeaa91875849efaea Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Wed, 11 Sep 2024 16:51:05 -0500 Subject: [PATCH] feat: allow to pass extra parameters for celery workers (cherry picked from commit c858d5d0a7e285f050eda6057b214a5313691b0d) --- tutorcelery/hooks.py | 1 + tutorcelery/patches/k8s-deployments | 3 +++ tutorcelery/patches/k8s-override | 3 +++ 3 files changed, 7 insertions(+) diff --git a/tutorcelery/hooks.py b/tutorcelery/hooks.py index eb46d8d..97d9f4c 100644 --- a/tutorcelery/hooks.py +++ b/tutorcelery/hooks.py @@ -20,6 +20,7 @@ class CELERY_WORKERS_ATTRS_TYPE(TypedDict): max_replicas: NotRequired[int] list_length: NotRequired[int] enable_keda: bool + extra_params: NotRequired[dict[str, str]] CELERY_WORKERS_CONFIG: Filter[dict[str, dict[str, CELERY_WORKERS_ATTRS_TYPE]], []] = ( diff --git a/tutorcelery/patches/k8s-deployments b/tutorcelery/patches/k8s-deployments index c0d2559..95b5ca1 100644 --- a/tutorcelery/patches/k8s-deployments +++ b/tutorcelery/patches/k8s-deployments @@ -31,6 +31,9 @@ spec: - "--hostname=edx.{{service}}.core.{{variant}}.%%h" - "--max-tasks-per-child=100" - "--queues=edx.{{service}}.core.{{variant}}" + {% for setting, value in config.get("extra_params", {}).items() %} + - "--{{setting}}={{value}}" + {% endfor %} env: - name: SERVICE_VARIANT value: {{service}} diff --git a/tutorcelery/patches/k8s-override b/tutorcelery/patches/k8s-override index 3d3eda8..6e78927 100644 --- a/tutorcelery/patches/k8s-override +++ b/tutorcelery/patches/k8s-override @@ -23,4 +23,7 @@ spec: {% else -%} - "--exclude-queues=edx.{{exclude}}.core.default" {% endif -%} + {% for setting, value in config.get("extra_params", {}).items() %} + - "--{{setting}}={{value}}" + {% endfor %} {% endfor %}