Skip to content

DAGs remain in the UI after renaming the dag_id in the same python file #11901

@wolfier

Description

@wolfier

Apache Airflow version: 1.10.12

What happened:

When I rename the dag_id, the new dag_id shows up in the UI but the old dag_id does not disappear and remains in the UI.

What you expected to happen:

When Airflow lists out the python files and tries to deactivate the deleted dags during dag processing, the old DAG's file location is still in the list of the alive DAG location because the new DAG is now defined in the old DAG's python file. Even when you manually set is_active to False in the metastore, the dag processing process will set it back to True.

This happens whether or not DAG serialization is enabled.

How to reproduce it:

I was able to reproduce it by following these steps:

  1. Add a python file in the dags folder and initialize the DAG
  2. Verify the dag shows up in the UI
  3. Change the dag_id in the same file to something else
  4. Verify the new dag shows up in the UI
  5. Both the old DAG and the new DAG are visible on the UI as well as the metadata db.
➜  dags pwd
/Users/alan/projects/astro/dags
➜  dags ls
wow.py
from datetime import datetime

from airflow.models import DAG


dag = DAG(
    dag_id='yay',
    schedule_interval='@once',
    start_date=datetime(2020, 1, 1),
    catchup=False
)

In the screenshot, both DAGs are marked as active but there only one DAG defined in wow.py.
Screen Shot 2020-10-27 at 6 31 40 PM

Anything else we need to know:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions