You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/05/17 11:00:33 UTC

[GitHub] [airflow] fbertos opened a new issue #15888: Abort a DAG Run

fbertos opened a new issue #15888:
URL: https://github.com/apache/airflow/issues/15888


   **Description**
   
   It would be great having a option to abort a DAG Runs through the REST API.
   
   **Use case / motivation**
   
   The proposed input params would be:
    - DAG_ID
    - DAG_RUN_ID
   
   The DAG Run should abort all its tasks running and mark them as "failed".
   
   **Are you willing to submit a PR?**
   
   **Related Issues**
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] andyalbert commented on issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
andyalbert commented on issue #15888:
URL: https://github.com/apache/airflow/issues/15888#issuecomment-894244066


   I'm new to this project, will try and pick it up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk edited a comment on issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
potiuk edited a comment on issue #15888:
URL: https://github.com/apache/airflow/issues/15888#issuecomment-852954898


   > > I still can't believe this hasn't been implemented yet, seems like a no brainer.
   > 
   > > Still, this is a basic feature that should have been implemented by apache a long time ago!
   > 
   > Many needed features and capabilities hasn't been implemented yet.
   > It's a community based project so what we have is what the community contribute.
   > 
   > We welcome PRs :)
   > 
   
   Indeed. We even will run workshop for first-time contributors at the Airflow Summit in July. More info soon. @alexing - would you be interested in taking part and contributing? It will be very cheap (all proceedings go to Apache Software Foundation). Happy to keep place for you. Contributing back is the best way to thank all the contributors who make the software available for free for you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] fbertos edited a comment on issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
fbertos edited a comment on issue #15888:
URL: https://github.com/apache/airflow/issues/15888#issuecomment-852925274


   Hi @alexing,
   
   We tried a different approach through the REST API to avoid touching the DB, this a code example:
   
   
   ```
       run_id = str(sys.argv[2])
   
       # We get first the task instance of the DAG run
       r = requests.get('http://localhost:8081/api/v1/dags/' + dag_id + '/dagRuns/' + str(run_id) + '/taskInstances?state=running', 
           auth=HTTPBasicAuth('admin', 'admin'))
   
       print(r.json()['task_instances'][0])
       task_id = r.json()['task_instances'][0]['task_id']
       execution_date = r.json()['task_instances'][0]['execution_date']
   
       # We set the tasks to failed
       r = requests.post('http://localhost:8081/api/v1/dags/' + dag_id + '/updateTaskInstancesState', 
           json={"dry_run": False,
               "task_id": str(task_id), 
               "execution_date": str(execution_date),
               "include_upstream": False,
               "include_downstream": False,
               "include_future": False,
               "include_past": False,
               "new_state": "**failed**" 
           },
           auth=HTTPBasicAuth('admin', 'admin'))
   
       if r.status_code == 200:
           print("Dag aborted")
   
   ```
   
   I hope it helps.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ephraimbuddy closed issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
ephraimbuddy closed issue #15888:
URL: https://github.com/apache/airflow/issues/15888


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #15888:
URL: https://github.com/apache/airflow/issues/15888#issuecomment-852954898


   > > I still can't believe this hasn't been implemented yet, seems like a no brainer.
   > 
   > > Still, this is a basic feature that should have been implemented by apache a long time ago!
   > 
   > Many needed features and capabilities hasn't been implemented yet.
   > It's a community based project so what we have is what the community contribute.
   > 
   > We welcome PRs :)
   > 
   
   Indeed. We even will run workshop for first-time contributors at the Airflow Summit in July. More info soon. @alexing - would you be interested in taking part and contributing. It will be very cheap (all proceedings go to Apache Software Foundation). Happy to keep place for you. Contributing back is the best way to thank all the contributors who make the software available for free for you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] alexing commented on issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
alexing commented on issue #15888:
URL: https://github.com/apache/airflow/issues/15888#issuecomment-852894830


   I still can't believe this hasn't been implemented yet, seems like a no brainer.
   
   I am currently in need of this feature, and the only workaround i found is modifying the DB and marking the relevant task instances as failed. Seems like overkill for such a small task.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] andyalbert removed a comment on issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
andyalbert removed a comment on issue #15888:
URL: https://github.com/apache/airflow/issues/15888#issuecomment-894244066


   I'm new to this project, will try and pick it up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] eladkal commented on issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
eladkal commented on issue #15888:
URL: https://github.com/apache/airflow/issues/15888#issuecomment-852947234


   > I still can't believe this hasn't been implemented yet, seems like a no brainer.
   
   > Still, this is a basic feature that should have been implemented by apache a long time ago!
   
   Many needed features and capabilities hasn't been implemented yet.
   It's a community based project so what we have is what the community contribute.
   
   We welcome PRs :)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] fbertos edited a comment on issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
fbertos edited a comment on issue #15888:
URL: https://github.com/apache/airflow/issues/15888#issuecomment-852925274


   Hi @alexing,
   
   We tried a different approach through the REST API to avoid touching the DB, this a code example:
   
   
   ```
       run_id = str(sys.argv[2])
   
       # We get first the task instance of the DAG run
       r = requests.get('http://localhost:8081/api/v1/dags/' + dag_id + '/dagRuns/' + str(run_id) + '/taskInstances?state=running', 
           auth=HTTPBasicAuth('admin', 'admin'))
   
       print(r.json()['task_instances'][0])
       task_id = r.json()['task_instances'][0]['task_id']
       execution_date = r.json()['task_instances'][0]['execution_date']
   
       # We set the tasks to failed
       r = requests.post('http://localhost:8081/api/v1/dags/' + dag_id + '/updateTaskInstancesState', 
           json={"dry_run": False,
               "task_id": str(task_id), 
               "execution_date": str(execution_date),
               "include_upstream": False,
               "include_downstream": False,
               "include_future": False,
               "include_past": False,
               "new_state": "failed" 
           },
           auth=HTTPBasicAuth('admin', 'admin'))
   
       if r.status_code == 200:
           print("Dag aborted")
   
   ```
   
   I hope it helps.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] fbertos commented on issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
fbertos commented on issue #15888:
URL: https://github.com/apache/airflow/issues/15888#issuecomment-852925274


   Hi @alexing,
   
   We tried a different approach through the REST API to avoid touching the DB, this a code example:
   
   
   ```
       run_id = str(sys.argv[2])
   
       # We get first the task instance of the DAG run
       r = requests.get('http://localhost:8081/api/v1/dags/' + dag_id + '/dagRuns/' + str(run_id) + '/taskInstances?state=running', 
           auth=HTTPBasicAuth('admin', 'admin'))
   
       print(r.json()['task_instances'][0])
       task_id = r.json()['task_instances'][0]['task_id']
       execution_date = r.json()['task_instances'][0]['execution_date']
   
       # We set the tasks to failed
       r = requests.post('http://localhost:8081/api/v1/dags/' + dag_id + '/updateTaskInstancesState', 
           json={"dry_run": False,
               "task_id": str(task_id), 
               "execution_date": str(execution_date),
               "include_upstream": False,
               "include_downstream": False,
               "include_future": False,
               "include_past": False,
               "new_state": "failed" 
           },
           auth=HTTPBasicAuth('admin', 'admin'))
   
       if r.status_code == 200:
           print("Dag aborted")
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] alexing commented on issue #15888: Abort a DAG Run

Posted by GitBox <gi...@apache.org>.
alexing commented on issue #15888:
URL: https://github.com/apache/airflow/issues/15888#issuecomment-852932953


   Well, we thought similar solutions for sure. Yours is a bit better designed! Thanks! I'll take into account.
   
   Still, this is a basic feature that should have been implemented by apache a long time ago!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org