Skip to content

Conversation

@kaxil
Copy link
Member

@kaxil kaxil commented Mar 17, 2025

closes #47499

TriggerDagRunOperator requires direct DB access to trigger DAG runs, which is not feasible under AIP-72 / Task SDK. Several approaches were considered:

  1. New Airflow API provider

    • Move TriggerDagRunOperator to a new provider built on top of the HTTP provider and Airflow API.
    • This would allow DAG authors to configure a dedicated Airflow connection.
    • However, the Public API currently requires API tokens and does not support username/password authentication, making setup cumbersome.
  2. Pass Task Token to API

    • Use Task Token from the controller DAG to authenticate API calls.
    • This would allow triggering DAGs in the same deployment using the execution API.
    • However, Task-identity tokens have not been implemented yet.
  3. Handle via Task Execution API (Chosen Approach)

    • Raise a TriggerDagRunOperator exception.
    • The Task Runner catches this and invokes a new endpoint in the Task Execution API to trigger the target DAG.

Since (2) is not yet available, this PR/commit implements (3) as a temporary solution.

Triggering in Action:

image image image image

Waiting for completion:
image

Skip when already exists:
image

image

Extra Operator Link:
image


TODO:

Will tackle in future PR as this is already big:


Finding:

TriggerDagRunOperator tests were never migrated to the standard provider — even though the operator code was. It means we never tested TriggerDagRunOperator (from Standard provider) on AF 2.x -- so a lot of tests are now broken .

image

Example Run: https://github.com/apache/airflow/actions/runs/13933237043/job/38995945264?pr=47882

@kaxil kaxil force-pushed the trigger-dr-operator branch 11 times, most recently from 5abb904 to 64e1cea Compare March 18, 2025 20:50
Copy link
Member

@ashb ashb left a comment

Choose a reason for hiding this comment

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

Looks like an okay approach given the current constraints.

@kaxil kaxil force-pushed the trigger-dr-operator branch from 64e1cea to e783d58 Compare March 18, 2025 23:53
@kaxil kaxil marked this pull request as ready for review March 18, 2025 23:53
@kaxil kaxil force-pushed the trigger-dr-operator branch 2 times, most recently from b431db5 to 97f0e64 Compare March 19, 2025 05:58
closes apache#47499

`TriggerDagRunOperator` requires direct DB access to trigger DAG runs, which is not feasible under AIP-72 / Task SDK. Several approaches were considered:

1. **New Airflow API provider**
   - Move `TriggerDagRunOperator` to a new provider built on top of the HTTP provider and Airflow API.
   - This would allow DAG authors to configure a dedicated Airflow connection.
   - However, the Public API currently requires API tokens and does not support username/password authentication, making setup cumbersome.

2. **Pass Task Token to API**
   - Use Task Token from the controller DAG to authenticate API calls.
   - This would allow triggering DAGs in the same deployment using the execution API.
   - However, Task-identity tokens have not been implemented yet.

3. **Handle via Task Execution API (Chosen Approach)**
   - Raise a `TriggerDagRunOperator` exception.
   - The Task Runner catches this and invokes a new endpoint in the Task Execution API to trigger the target DAG.

Since (2) is not yet available, this PR/commit implements (3) as a temporary solution.
@kaxil kaxil force-pushed the trigger-dr-operator branch from 97f0e64 to 9e46306 Compare March 19, 2025 06:47
@kaxil kaxil merged commit 4b83391 into apache:main Mar 19, 2025
88 checks passed
@kaxil kaxil deleted the trigger-dr-operator branch March 19, 2025 07:42
agupta01 pushed a commit to agupta01/airflow that referenced this pull request Mar 21, 2025
closes apache#47499

`TriggerDagRunOperator` requires direct DB access to trigger DAG runs, which is not feasible under AIP-72 / Task SDK. Several approaches were considered:

1. **New Airflow API provider**
   - Move `TriggerDagRunOperator` to a new provider built on top of the HTTP provider and Airflow API.
   - This would allow DAG authors to configure a dedicated Airflow connection.
   - However, the Public API currently requires API tokens and does not support username/password authentication, making setup cumbersome.

2. **Pass Task Token to API**
   - Use Task Token from the controller DAG to authenticate API calls.
   - This would allow triggering DAGs in the same deployment using the execution API.
   - However, Task-identity tokens have not been implemented yet.

3. **Handle via Task Execution API (Chosen Approach)**
   - Raise a `TriggerDagRunOperator` exception.
   - The Task Runner catches this and invokes a new endpoint in the Task Execution API to trigger the target DAG.

Since (2) is not yet available, this PR/commit implements (3) as a temporary solution.
shubham-pyc pushed a commit to shubham-pyc/airflow that referenced this pull request Mar 22, 2025
closes apache#47499

`TriggerDagRunOperator` requires direct DB access to trigger DAG runs, which is not feasible under AIP-72 / Task SDK. Several approaches were considered:

1. **New Airflow API provider**
   - Move `TriggerDagRunOperator` to a new provider built on top of the HTTP provider and Airflow API.
   - This would allow DAG authors to configure a dedicated Airflow connection.
   - However, the Public API currently requires API tokens and does not support username/password authentication, making setup cumbersome.

2. **Pass Task Token to API**
   - Use Task Token from the controller DAG to authenticate API calls.
   - This would allow triggering DAGs in the same deployment using the execution API.
   - However, Task-identity tokens have not been implemented yet.

3. **Handle via Task Execution API (Chosen Approach)**
   - Raise a `TriggerDagRunOperator` exception.
   - The Task Runner catches this and invokes a new endpoint in the Task Execution API to trigger the target DAG.

Since (2) is not yet available, this PR/commit implements (3) as a temporary solution.
nailo2c pushed a commit to nailo2c/airflow that referenced this pull request Apr 4, 2025
closes apache#47499

`TriggerDagRunOperator` requires direct DB access to trigger DAG runs, which is not feasible under AIP-72 / Task SDK. Several approaches were considered:

1. **New Airflow API provider**
   - Move `TriggerDagRunOperator` to a new provider built on top of the HTTP provider and Airflow API.
   - This would allow DAG authors to configure a dedicated Airflow connection.
   - However, the Public API currently requires API tokens and does not support username/password authentication, making setup cumbersome.

2. **Pass Task Token to API**
   - Use Task Token from the controller DAG to authenticate API calls.
   - This would allow triggering DAGs in the same deployment using the execution API.
   - However, Task-identity tokens have not been implemented yet.

3. **Handle via Task Execution API (Chosen Approach)**
   - Raise a `TriggerDagRunOperator` exception.
   - The Task Runner catches this and invokes a new endpoint in the Task Execution API to trigger the target DAG.

Since (2) is not yet available, this PR/commit implements (3) as a temporary solution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TriggerDagRunOperator is failing for reason 'Direct database access via the ORM is not allowed in Airflow 3.0'

2 participants