Skip to content
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

Add option to clear only failed tasks in a graph view #38217

Merged
merged 1 commit into from Mar 25, 2024

Conversation

tirkarthi
Copy link
Contributor

This PR adds a new option to clear only failed tasks in a dag run. The backend API will accept a new parameter only_failed which by default is False for backwards compatibility.

closes: #38031
related: #38031

image

@boring-cyborg boring-cyborg bot added area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues labels Mar 16, 2024
@tirkarthi
Copy link
Contributor Author

Nit: I have added "clear only failed tasks" but can make it "clear failed tasks" as per original issue since when the failed task is cleared the downstream tasks that have upstream_failed state are also cleared.

Copy link
Collaborator

@dirrao dirrao left a comment

Choose a reason for hiding this comment

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

Nice Feature. LGTM.

@eladkal
Copy link
Contributor

eladkal commented Mar 21, 2024

failed tasks are just failed or also upstream_failed?
I am not sure if the request in the issue is for status failed or actually to tasks that are in terminal error state.
I think it's odd to clear only failed without upstream_failed but if people find it useful then we should have it

@eladkal eladkal added this to the Airflow 2.9.0 milestone Mar 21, 2024
@eladkal eladkal added the type:improvement Changelog: Improvements label Mar 21, 2024
@eladkal eladkal changed the title Add button to clear only failed tasks in a dagrun. Add option to clear only failed tasks in a graph view Mar 21, 2024
@bbovenzi
Copy link
Contributor

This is the equivalent of "Clear task" with the parameters upstream+downstream+only_failed set to true, right?

@tirkarthi
Copy link
Contributor Author

It would clear the failed tasks for the selected run (wit option to select downstream or not).

@eladkal I overlooked this part in the original issue. First I thought passing failed only clears failed tasks but it also cleared upstream failed. I found it useful since after the failed tasks is cleared and it succeeds having the downstream task might result in an extra action if not for the behaviour. Then I found the code as below where the logic is present. The request was also for dags with large number of tasks where downstream=True requirement means this will only clear upstream_failed downstream tasks and not success downstream tasks. Adding downstream or not option will change this into a modal similar to the clear task button on a dagrun level.

@Pad71 let me know if I missed something.

airflow/airflow/models/dag.py

Lines 2333 to 2334 in 3840ec6

if only_failed:
state += [TaskInstanceState.FAILED, TaskInstanceState.UPSTREAM_FAILED]

@tirkarthi
Copy link
Contributor Author

This is the equivalent of "Clear task" with the parameters upstream+downstream+only_failed set to true, right?

Yes, as per my understanding of the code.

@Pad71
Copy link

Pad71 commented Mar 21, 2024

It would clear the failed tasks for the selected run (wit option to select downstream or not).

@eladkal I overlooked this part in the original issue. First I thought passing failed only clears failed tasks but it also cleared upstream failed. I found it useful since after the failed tasks is cleared and it succeeds having the downstream task might result in an extra action if not for the behaviour. Then I found the code as below where the logic is present. The request was also for dags with large number of tasks where downstream=True requirement means this will only clear upstream_failed downstream tasks and not success downstream tasks. Adding downstream or not option will change this into a modal similar to the clear task button on a dagrun level.

@Pad71 let me know if I missed something.

airflow/airflow/models/dag.py

Lines 2333 to 2334 in 3840ec6

if only_failed:
state += [TaskInstanceState.FAILED, TaskInstanceState.UPSTREAM_FAILED]

@tirkarthi Yeah, the requirement is - clear all failed tasks in selected dag run and clear their downstream tasks in upstream_failed state.

@tirkarthi
Copy link
Contributor Author

Thanks @Pad71 , the PR implements the requirement.

@Pad71
Copy link

Pad71 commented Mar 22, 2024

Thanks @Pad71 , the PR implements the requirement.

Thank you @tirkarthi and all involved! Good job.

if you guys have a time to check this discussion, it would be great.
#38181

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

Looks good, LGTM!

@bbovenzi bbovenzi merged commit b1473eb into apache:main Mar 25, 2024
48 checks passed
utkarsharma2 pushed a commit to astronomer/airflow that referenced this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the new option "Clear Failed Tasks" to the DagRun Clear option button
6 participants