Search code examples
airflowdirected-acyclic-graphs

Why dag show multiple owner


I have created one dag and assigned myself as dag owner in default args. But since it started it shows two owners "Myself", "airflow". Why this strange behavior in airflow. Not able to figure out the root cause. Please advice.


Solution

  • In Airflow you can set owner on task level:

    EmpyOperator(task_id="task1", owner="owner1")
    EmpyOperator(task_id="task2", owner="owner2")
    

    On DAG level the owner is property aggregates the owners of all tasks associate to this DAG. You can see it in the source code.

    Thus:

    with DAG(dag_id="my_dag", ...):
        EmpyOperator(task_id="task1", owner="owner1")
        EmpyOperator(task_id="task2", owner="owner2")
    

    Will have 2 owners: owner1, owner2

    Normally it is common to set owner via default_args thus:

    default_args = {
        'owner': 'some_owner',
    }
    with DAG(dag_id="my_dag", default_args=default_args, ...):
        EmpyOperator(task_id="task1")
        EmpyOperator(task_id="task2")
    

    In this case no need to handle setting owner on task level and all tasks with this DAG will have the same owner.