Skip to content

Superset worker has no lifecycle preStop command #33513

@otunyk-smtc

Description

@otunyk-smtc

Bug description

I noticed that Superset worker is not gracefully shuts down when it is deployed to k8s, as a result a celery signal worker_shutdown is never triggered and tasks can be aborted without let them to complete. Also due to this issue workers status keeps as online while should be marked as offline on pod termination.
I tried both celery signals and SIGINT for bash and python and it is not catching the process termination.
Also I noticed that worker deployment (helm/superset/templates/deployment-worker.yaml) has no lifecycle preStop command. As soon as I added lifecycle preStop as this celery --app=superset.tasks.celery_app:app control shutdown --destination=celery@$HOSTNAME it solves the issue with gracefull shutdown.

Please add lifecycle preStop to the worker deployment-worker.yaml and/or values.yaml

Here is my patch I used with kubectl:

spec:
  template:
    spec:
      containers:
        - name: {{ .Chart.Name }}
          lifecycle:
            preStop:
              exec:
                command:
                  - /bin/sh
                  - '-c'
                  - celery --app=superset.tasks.celery_app:app control shutdown --destination=celery@$HOSTNAME

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions