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

Fix airflow celery stop to accept the pid file. #17278

Merged
merged 1 commit into from
Jul 30, 2021
Merged

Fix airflow celery stop to accept the pid file. #17278

merged 1 commit into from
Jul 30, 2021

Conversation

santosh-d3vpl3x
Copy link
Contributor

@santosh-d3vpl3x santosh-d3vpl3x commented Jul 28, 2021

Background
Airflow celery cli provides a nice interface to launch workers and stop them. This cli setup works very well when there is one worker running on node without a custom PID specified. But if a worker is launched with custom --pid file then airflow celery stop command is not capable of stopping the worker. In our setup, we run multiple workers on same node subscribed to different queues. The only way to stop worker is to provide SIGTERM, which isn't always the best strategy as it is not always graceful.

Changes made
Add an additional argument to the airflow celery stop command, --pid. If this argument is present then the cli will kill worker associated with pid present in specified pidfile.

@boring-cyborg
Copy link

boring-cyborg bot commented Jul 28, 2021

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@santosh-d3vpl3x santosh-d3vpl3x marked this pull request as draft July 28, 2021 00:56
@santosh-d3vpl3x santosh-d3vpl3x marked this pull request as ready for review July 28, 2021 00:57
Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the linter will complain, and we probably need to make sure:

  1. The custom PID path actually works as we expect.
  2. The --pid-less command form still continues to work.

In other words, you should not modify the current test_same_pid_file_is_used_in_start_and_stop test, and instead add a new test that runs the worker in a non-standard PID file location to check the --pid option actually has an effect.

Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of defensive coding improvements, the logic lgtm!

airflow/cli/commands/celery_command.py Outdated Show resolved Hide resolved
tests/cli/commands/test_celery_command.py Outdated Show resolved Hide resolved
@uranusjr uranusjr merged commit b814a58 into apache:main Jul 30, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 30, 2021

Awesome work, congrats on your first merged pull request!

@uranusjr
Copy link
Member

This bot makes me happy every time.

denimalpaca added a commit to denimalpaca/airflow that referenced this pull request Aug 2, 2021
Fix `airflow celery stop` to accept the pid file. (apache#17278)

Fix isort (apache#17330)

Fix failing celery test (apache#17337)

This change fixes failing test due to mocking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants