Skip to content

Conversation

@OscarLigthart
Copy link
Contributor

@OscarLigthart OscarLigthart commented Dec 23, 2025

Context

The ability to clear newly introduced tasks in an already existing DAG run seems not to have been added to Airflow 3 yet.

image

The button in the UI is disabled at all times.

Implementation

In this PR I try to start with the basic requirement, which is to add functionality to the dag.clear() function that ensures only newly added tasks are cleared.

Questions to Reviewer

  • I'm not sure if the use of DagBag is appropriate here. It works, but I am not as familiar with best practices in Airflow as I would like to be yet. I'm also not fully aware of how this was implemented in Airflow 2, and since I'm touching core Airflow things here, please let me know if there's anything off about my approach. Would love to learn more!
  • Are there any existing plans to add this back that we can align on? I see there is an argument run_on_latest_version, but I am unsure of its purpose. I've seen it's experimental and I wonder if it is at all involved with the issue attached to this PR.

Issue

See below the related issues.

related: #57051
related: #56250


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@potiuk potiuk force-pushed the feat/dag-clear-only-new-tasks branch from 505c4a3 to c822b20 Compare January 7, 2026 17:45
Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good

from airflow.models.taskinstance import clear_task_instances

state: list[TaskInstanceState] = []

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but Since it indeed touches core airflow definitions, I would love if other maintainers more familiar with it will take a look - I am afraid this might not be optimal way of doing it and possibly it can be done simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review and pointing this out. I have a similar feeling, but lack the context to come up with said simpler solution.

Would also appreciate any more opinions from others!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashb @bolkedebruin - could either of you have a second glance at this PR?

@NilsJPWerner NilsJPWerner mentioned this pull request Jan 9, 2026
19 tasks
@OscarLigthart
Copy link
Contributor Author

@potiuk do you think we can go ahead with this? Or would you like me to chase after some more reviews?

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.

2 participants