Repository navigation
fix(airflow): stop an active run when deleting its DAG #36349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1e02ed1
fix(airflow): stop an active run when deleting its DAG
sonika-shah 48d97ea
fix(airflow): stop runs only for Airflow's running-task refusal, and …
sonika-shah 8219fbb
docs(decisions): record that deleting a pipeline DAG stops its active…
sonika-shah b0b00d9
fix(airflow): keep the delete retry's run stop in the caller's transa…
sonika-shah c3a8324
test(airflow): assert a failed delete also keeps the generated config
sonika-shah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
docs/decisions/2026-10-29-deleting-a-pipeline-dag-stops-its-active-run.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Deleting a pipeline's Airflow DAG stops its active run instead of failing | ||
|
|
||
| - **Status:** Accepted | ||
| - **Revisions:** v1 2026-10-29 (initial) | ||
| - **Deciders:** Sonika Shah | ||
| - **Guard:** `test_delete_stops_a_running_dag_and_removes_it`, `test_failed_delete_leaves_active_runs_untouched` in `openmetadata-airflow-apis/tests/integration/operations/test_dag_lifecycle.py` | ||
| - **Related:** #36350, #36349, #36267 | ||
|
|
||
| ## Context | ||
|
|
||
| Airflow's `delete_dag` refuses while any task instance of the DAG is running. The server commits | ||
| the hard delete of an ingestion pipeline (`cleanup()`) before `postDelete` asks the runner to | ||
| remove the DAG, so a refusal cannot keep the pipeline: returning 409 from the plugin left the | ||
| pipeline deleted and the DAG in Airflow, still scheduled, with nothing in OpenMetadata to manage it. | ||
|
|
||
| ## Decision | ||
|
|
||
| When `delete_dag` raises because a task instance is running, the plugin's delete operation fails | ||
| the DAG's unfinished runs and task instances (as `kill` does) and deletes again, in one | ||
| transaction: if the retried delete also fails, nothing is committed, so the runs stay as they were | ||
| and the DAG files stay on disk. Any other Airflow error propagates the same way. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Every delete path (direct, by name, async, force, service recursive cascade, app uninstall) | ||
| removes the DAG, because all of them reach this one plugin endpoint. | ||
| - Deleting a pipeline mid-run ends that run as failed; the running task is terminated by Airflow. | ||
| - A task that starts running between the stop and the retry makes the retry fail; the delete then | ||
| fails as it did before this record, with the run left untouched. | ||
| - Revisit only if the server moves the runner teardown ahead of its DB commit; then refusing the | ||
| delete would become a viable alternative. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.