Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop/kill Airflow tasks from the UI

How can I stop/kill a running task on Airflow UI? I am using LocalExecutor. Even if I use CeleryExecutor, how do can I kill/stop the running task?

like image 307
Chetan J Avatar asked Apr 26 '17 10:04

Chetan J


People also ask

How do I stop a task in Airflow?

Simply set the task to failed state will stop the running task.

How do you kill PID in Airflow?

So, we will first have to find the parent PID of the gunicorn process and then kill the parent process. should terminate the webserver. If simply running kill (i.e., sending SIGTERM) for these processes does not work you can always try sending SIGKILL: kill -9 <pid> . This should definitely kill them.

How do I turn off the Airflow DAG?

If your DAG is not written to handle its catchup (i.e., not limited to the interval, but instead to Now for instance.), then you will want to turn catchup off. This can be done by setting catchup = False in DAG or catchup_by_default = False in the configuration file.

Does Airflow have a UI?

The Airflow UI makes it easy to monitor and troubleshoot your data pipelines. Here's a quick overview of some of the features and visualizations you can find in the Airflow UI.


3 Answers

In the DAGs screen you can see the running tasks:

enter image description here

Example

On 'Recent Tasks' press the running icon and Airflow will automatically run the search query with the filters for the Dag Id and State equal to 'running' and show the results on the Task Instances screen (you can find it manually on the tab Browse > Task Instances).

There you can select the presented tasks and set them to another state or delete them.

Please notice that if the DAG is currently running, the Airflow scheduler will start again the tasks you delete. So either you stop the DAG first by changing its state or stop the scheduler (if you are running on a test environment).

like image 113
Jorge Almeida Avatar answered Oct 12 '22 21:10

Jorge Almeida


Simply set the task to failed state will stop the running task.

[2019-09-17 23:53:28,040] {logging_mixin.py:82} INFO - [2019-09-17 23:53:28,039] {jobs.py:2695} WARNING - State of this instance has been externally set to failed. Taking the poison pill.
[2019-09-17 23:53:28,041] {helpers.py:240} INFO - Sending Signals.SIGTERM to GPID 20977
like image 30
kk17 Avatar answered Oct 12 '22 21:10

kk17


Set task to failed state:

  1. Click task enter image description here

  2. Set task to "Failed" state enter image description here

  3. All subsequent tasks (if there are any) will also be marked as failed: enter image description here

like image 13
Hrvoje Avatar answered Oct 12 '22 22:10

Hrvoje