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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion airflow/www/static/js/api/useClearRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ export default function useClearRun(dagId: string, runId: string) {
const { startRefresh } = useAutoRefresh();
return useMutation(
["dagRunClear", dagId, runId],
({ confirmed = false }: { confirmed: boolean }) => {
({
confirmed = false,
only_failed = false,
}: {
confirmed: boolean;
only_failed?: boolean;
}) => {
const params = new URLSearchParamsWrapper({
csrf_token: csrfToken,
confirmed,
only_failed,
dag_id: dagId,
dag_run_id: runId,
}).toString();
Expand Down
7 changes: 7 additions & 0 deletions airflow/www/static/js/dag/details/dagRun/ClearRun.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ const ClearRun = ({ runId, ...otherProps }: Props) => {
onClear({ confirmed: true });
};

const clearFailedTasks = () => {
onClear({ confirmed: true, only_failed: true });
};

const queueNewTasks = () => {
onQueue({ confirmed: true });
};
Expand Down Expand Up @@ -103,6 +107,9 @@ const ClearRun = ({ runId, ...otherProps }: Props) => {
</MenuButton>
<MenuList>
<MenuItem onClick={clearExistingTasks}>Clear existing tasks</MenuItem>
<MenuItem onClick={clearFailedTasks}>
Clear only failed tasks
</MenuItem>
<MenuItem onClick={queueNewTasks}>Queue up new tasks</MenuItem>
</MenuList>
</Menu>
Expand Down
2 changes: 2 additions & 0 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,7 @@ def dagrun_clear(self, *, session: Session = NEW_SESSION):
dag_id = request.form.get("dag_id")
dag_run_id = request.form.get("dag_run_id")
confirmed = request.form.get("confirmed") == "true"
only_failed = request.form.get("only_failed") == "true"

dag = get_airflow_app().dag_bag.get_dag(dag_id)
dr = dag.get_dagrun(run_id=dag_run_id)
Expand All @@ -2337,6 +2338,7 @@ def dagrun_clear(self, *, session: Session = NEW_SESSION):
origin=None,
recursive=True,
confirmed=confirmed,
only_failed=only_failed,
session=session,
)

Expand Down