Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if projects have custom names for the celery workers/queues #165

Open
1 of 7 tasks
SilviaAmAm opened this issue Jan 14, 2025 · 4 comments · Fixed by #168
Open
1 of 7 tasks

Check if projects have custom names for the celery workers/queues #165

SilviaAmAm opened this issue Jan 14, 2025 · 4 comments · Fixed by #168
Assignees

Comments

@SilviaAmAm
Copy link
Collaborator

SilviaAmAm commented Jan 14, 2025

Discussion: https://github.com/maykinmedia/charts/pull/164/files#r1914893573

Most projects use this to start celery:

QUEUE=${1:-${CELERY_WORKER_QUEUE:=celery}} 
WORKER_NAME=${2:-${CELERY_WORKER_NAME:="${QUEUE}"@%n}}

exec celery --workdir src --app proj.celery worker \
    -Q $QUEUE \
    -n $WORKER_NAME \
   ...

Projects that need changing:

  • Open forms
  • Open zaak
  • Open notificaties
  • Open inwoner
  • Objecten
  • Open archiefbeheer
  • Open klant
@SilviaAmAm SilviaAmAm self-assigned this Jan 14, 2025
@SilviaAmAm
Copy link
Collaborator Author

SilviaAmAm commented Jan 15, 2025

Spent some time understanding how the celery_worker.sh works:

  • if /celery_worker.sh is called with positional args (/celery_worker.sh apple potato), this takes precedence and gives a worker celery@apple listening to queue potato.
    Note: if the worker name does not contain the symbol @, it is considered the hostname and celery@ is prepended to it: https://github.com/celery/celery/blob/fe761416f4d9269b780a13cc1131e2a16945937f/celery/utils/nodenames.py#L79
  • If there are no positional arguments and the environment variables CELERY_WORKER_QUEUE and WORKER_NAME are set, then those will be used.
  • If nothing is set, it defaults to worker celery@hostname listening to queue celery.

The way the script celery_worker.sh is run in the helm charts doesn't use the positional args, so I guess there is no need to support this possibility (at least for now).

The celery docs don't mention that the hostname "must" include a @ symbol, so then we should also in the helm chart figure out if the we need to use celery@${WORKER_NAME} or ${WORKER_NAME} or celery@${HOSTNAME}

Edit after discussion with Sergei:

In celery, the -Q option can be a comma separated list of strings so that workers can listen to multiple queues (https://docs.celeryq.dev/en/v5.4.0/reference/cli.html#cmdoption-celery-worker-Q). We don't support this with the celery_worker.sh script. We use the CELERY_WORKER_QUEUE variable to set the name of a queue per worker. In our ansible deployments, it is possible to define multiple worker containers that listen to different queues. In the helm charts this is not yet supported, but should be kept in mind for now.

@sergei-maertens
Copy link
Member

I'm open for simplifying things and dropping support for positional arguments if it's not used anywhere!

SilviaAmAm added a commit to maykinmedia/open-archiefbeheer that referenced this issue Jan 22, 2025
SilviaAmAm added a commit to maykinmedia/open-archiefbeheer that referenced this issue Jan 22, 2025
SilviaAmAm added a commit to maykinmedia/open-klant that referenced this issue Jan 22, 2025
SilviaAmAm added a commit to open-zaak/open-zaak that referenced this issue Jan 22, 2025
SilviaAmAm added a commit to open-zaak/open-notificaties that referenced this issue Jan 22, 2025
SilviaAmAm added a commit to open-formulieren/open-forms that referenced this issue Jan 22, 2025
SilviaAmAm added a commit to maykinmedia/objects-api that referenced this issue Jan 22, 2025
SilviaAmAm added a commit to maykinmedia/open-inwoner that referenced this issue Jan 22, 2025
SilviaAmAm added a commit that referenced this issue Jan 22, 2025
SilviaAmAm added a commit that referenced this issue Jan 22, 2025
SilviaAmAm added a commit that referenced this issue Jan 22, 2025
alextreme added a commit that referenced this issue Jan 22, 2025
[#165] Support different queue/worker names in probe OAB
@SilviaAmAm
Copy link
Collaborator Author

Only OAB complete

@SilviaAmAm SilviaAmAm reopened this Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants