The JIRA issue is optional, but if there is already one that is relevant link to it here. Using the Jira issue macro is preferred.
|
Currently, DAGs are discovered by Airflow through traversing the all the files under $AIRFLOW_HOME/dags, looking for files that contains "airflow" and "DAG" in the content, which is not efficient. We need to find a better way for Airflow to discover the DAGs.
Is there anything special to consider about this AIP? Downsides? Difficultly in implementation or rollout etc?
I am proposing to introduce DAG manifest, an easier and more efficient way for Airflow to discover DAGs. The DAG manifest would be composed with manifest entries, where each entry represents a single DAG and contains in formation about where to find the DAG.
dag_manifest_entry:
dag_id: the DAG ID
uri: where dag can be found, DAG locations will be given via URI, i.e. s3://my-bucket/dag1.zip, local:////dags/day1.zip
conn_id: connection id to use to interact with remote location |
Airflow services will look at $AIRFLOW_HOME/manifest.json for the DAG manifest. The manifest.json contains all the DAG entries. We should expect a manifest.json like:
[
"dag_1": {
"uri": "local://dags/hello.py"
},
"dag_2": {
"uri": "s3://dags/superhero.py"
}
] |
The manifest can also be generated by a callable supplied in the airflow.cfg that would generate a list of entries when called, i.e
[core] # callable to fetch dag manifest list dag_manifest_entries = my_config.get_dag_manifest_entries |
The DAG manifest can be stored on S3 and my_config.get_dag_manifest_entries will read the manifest from S3.
An easier and more efficient approach for Airflow DAG discovery.
All users attempted to upgrade to the latest.
Users need to run a migration script to populate the DAG manifest.
Airflow discovers DAGs by looking at DAG manifest without traversing through all the files in the filesystem.