-
Couldn't load subscription status.
- Fork 15.9k
Description
Apache Airflow Provider(s)
git
Versions of Apache Airflow Providers
No response
Apache Airflow version
3.0.2
Operating System
Ubuntu 20.04.6 LTS
Deployment
Virtualenv installation
Deployment details
No response
What happened
When using GitDagBundle with supports_versioning=True, Airflow DAG Processor fails to execute DAG callbacks because it cannot find the materialized code under versions/<commit_hash>/.
Only the tracking_repo/ folder is updated with the latest version, but when a DAG-level callback (e.g. on_success_callback, on_failure_callback) is triggered, the callback request sent to the DAG Processor points to the versioned folder (e.g. /dag-bundles/git_xxx/versions/<commit_hash>/dag.py), which does not exist by default.
This leads to a failure in the DAG Processor when trying to load the DAG from the file. Specifically, inside DagFileProcessor._execute_dag_callbacks, the following code fails:
dag = dagbag.dags[request.dag_id] # returns empty
This happens because dagbag.process_file() cannot find the DAG file at the specified path (versions/<commit_hash>/...), and so the DAG is never loaded, and the callback is silently skipped.
What you think should happen instead
The DAG Processor should also materialize the correct version of the DAG source code (i.e., clone the Git repository to the appropriate versions/<commit_hash> path) before attempting to load and execute DAG-level callbacks.
How to reproduce
- Use GitDagBundle with supports_versioning=True.
- Define a DAG-level
on_failure_callbackoron_success_callback. - Deploy a new Git version and trigger a DAG run that invokes the callback.
- The DAG tasks execute successfully.
- But DAG callback fails because the path in the callback request is under versions/<commit_hash>/, which is not materialized
- As a workaround, we patched GitDagBundle.refresh() to also clone the repo into the
versions/directory.
Anything else
In our environment, DAGs are triggered via Asset, but this should not affect the behavior.
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct