Skip to content

Add reattach_on_existing option to TriggerDagRunOperator#69839

Open
crobertson-astro wants to merge 1 commit into
apache:mainfrom
crobertson-astro:trigger-dagrun-reattach-on-clear
Open

Add reattach_on_existing option to TriggerDagRunOperator#69839
crobertson-astro wants to merge 1 commit into
apache:mainfrom
crobertson-astro:trigger-dagrun-reattach-on-clear

Conversation

@crobertson-astro

Copy link
Copy Markdown

Add a reattach_on_existing option to TriggerDagRunOperator.

When a triggered Dag run fails on a single task, users often fix it by hand in the triggered Dag (mark the task success, clear it, or re-run it) and then want the triggering task to resume waiting on that same run. Today, re-running the triggering task either wipes the manual fix (reset_dag_run=True clears the whole triggered run) or raises DagRunAlreadyExists (the default). Neither lets the triggering task simply re-attach.

With reattach_on_existing=True, a cleared triggering task attaches to the existing triggered Dag run and — with wait_for_completion=True — polls or defers on it until it reaches an allowed or failed state, preserving the manual intervention. reset_dag_run and skip_when_already_exists keep precedence.

Implemented on both the Airflow 2.x path (operator DagRunAlreadyExists handling) and the Airflow 3.x path (DagRunTriggerException + task-SDK execution), with tests covering reattach, wait-success, wait-failed, deferrable, and reset/skip precedence on both paths.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8) orchestrating Astronomer Otto (0.1.18)

Generated-by: Claude Code (Opus 4.8) following the guidelines

When a triggered Dag run fails on a single task, users often fix it by hand
in the triggered Dag (marking the task success, clearing it, or re-running it)
and then want the triggering task to resume waiting on that same run. Today the
only ways to re-run the triggering task are reset_dag_run, which wipes the
manual fix by clearing the whole triggered run, or the default, which raises
DagRunAlreadyExists. Neither lets the triggering task simply re-attach.

reattach_on_existing lets a cleared triggering task attach to the existing
triggered Dag run and, with wait_for_completion, poll or defer on it until it
reaches an allowed or failed state, preserving any manual intervention.
reset_dag_run and skip_when_already_exists keep precedence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant