Skip to content

Commit 0d055e1

Browse files
committed
[DOP-30579] Change worker image entrypoint
1 parent 93a473d commit 0d055e1

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

docker-compose.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ services:
104104
dockerfile: docker/Dockerfile.worker
105105
context: .
106106
target: test
107-
command: --loglevel=info -Q 123-test_queue
107+
command: --queues 123-test_queue # Queue slug
108108
entrypoint: [coverage, run, -m, celery, -A, tests.test_integration.celery_test, worker, --max-tasks-per-child=1]
109109
env_file: .env.docker.test
110110
environment:

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ services:
8181
dockerfile: docker/Dockerfile.worker
8282
context: .
8383
target: prod
84-
command: -E -Q 123-test_queue # Queue.slug
84+
command: worker --events --queues 123-test_queue # Queue.slug
8585
volumes:
8686
- ./config.docker.yml:/app/config.yml
8787
depends_on:

docker/entrypoint_worker.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ case "$1" in
8181
)
8282
;;
8383

84-
*)
84+
worker)
8585
# https://docs.celeryq.dev/en/stable/userguide/workers.html#max-tasks-per-child-setting
8686
# Required to start each Celery task in separated process, avoiding issues with global Spark session object
8787
CMD=(
@@ -92,6 +92,10 @@ case "$1" in
9292
"$@"
9393
)
9494
;;
95+
96+
# Any other command to run
97+
*)
98+
CMD=("$@")
9599
esac
96100

97101
# Execute the container CMD under tini for better hygiene
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Allow using SyncMaster worker image as ``spark.kubernetes.container.image``.
2+
3+
Worker container command should be changed from ``--queues 123-myqueue`` to ``worker --queues 123-myqueue``.

docs/changelog/next_release/295.feature.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/reference/worker/index.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ executes them and updates status & log url in :ref:`database`. Implemented using
1111
Each worker process is bound to one ot more Queues. You have to created it before starting a worker.
1212
This can be done via :ref:`frontend` or via :ref:`server` REST API.
1313

14-
Queue field ``slug`` value is then should be passed to Celery argument ``-Q``.
15-
For example, for slug ``123-test_queue`` this should be ``-Q 123-test_queue``.
14+
Queue field ``slug`` value is then should be passed to Celery worker argument ``--queues``.
15+
For example, for slug ``123-test_queue`` this should be ``--queues 123-test_queue``.
16+
17+
Worker can listen multiple queues at the same time, you can pass a list with ``,`` as delimiter.
1618

1719
Install & run
1820
-------------
@@ -25,6 +27,7 @@ With docker
2527
* Go to `frontend <http://localhost:3000>`
2628
* Create new Group
2729
* Create Queue in this group, and then get **Queue.slug** (e.g. ``123-test_queue``)
30+
* Pass queue slug as ``--queues $slug`` into ```worker:command`` section of ``docker-compose.yml`` (see below)
2831
* Run the following command:
2932

3033
.. code:: console
@@ -79,19 +82,19 @@ Without docker
7982

8083
.. code-block:: console
8184
82-
$ python -m celery -A syncmaster.worker.celery worker -Q 123-test_queue --max-tasks-per-child=1
85+
$ python -m celery -A syncmaster.worker.celery worker --queues 123-test_queue --max-tasks-per-child=1
8386
8487
You can specify options like concurrency and queues by adding additional flags:
8588

8689
.. code-block:: bash
8790
88-
$ python -m celery -A syncmaster.worker.celery worker -Q 123-test_queue --max-tasks-per-child=1 --concurrency=4 --loglevel=info
91+
$ python -m celery -A syncmaster.worker.celery worker --queues 123-test_queue --max-tasks-per-child=1 --concurrency=4
8992
9093
Refer to the `Celery <https://docs.celeryq.dev/en/stable/>`_ documentation for more advanced start options.
9194

9295
.. note::
9396

94-
``--max-tasks-per-child=1`` flag is important!
97+
``--max-tasks-per-child=1`` flag is important for Spark to properly work!
9598

9699
See also
97100
--------

0 commit comments

Comments
 (0)