Reputation: 3461
Running Airflow 1.9.0 with python 2.7. How do I gracefully stop a DAG?
In this case, I have a DAG that's running a file upload with bad code that causes everything to take 4 times as long, and I'd really prefer not to have to wait a day for it to finally time out (timeout is set to 10 hours).
The DAG looks for a tar file. When it finds one, it goes through every file in the tar, looking for files to process, and processes them.
I could not find any way to stop the DAG. I tried clicking on the "Running" circle in the "DAG Runs" column (the one to the right). It let me select the process and mark it as "failed". But it didn't stop running.
I tried clicking on the "Running" circle in the "Recent Tasks" column (the one to the left). It let me select processes, but trying to set them to filed (or to success), generated an exception in Airflow
Upvotes: 9
Views: 22347
Reputation: 191
You can add a Sensor Operator which runs in parallel with your Task which you want killed.
The sensor should monitor the value of some Variable and should complete when it detects a certain value in the Variable, like 'STOP' let's say.
The Sensor should be followed by a BashOperator Task which shoul d kill your long running Task using a command like below:
kill -9 $(ps -ef| grep | grep | grep -v grep | awk '{print $2;}')
Upvotes: 2
Reputation: 4366
If you constructed your process the way it sounds like you did, you won't be able to stop it from Airflow. You'll need to find the process identifier that is executing and forcibly terminate it to get it to actually stop.
Upvotes: 3