You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org> on 2025/09/15 04:56:44 UTC
[PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
KlarenceNicolasCatalan opened a new pull request, #55660:
URL: https://github.com/apache/airflow/pull/55660
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
### Why
---
This is a pull request based on the raised issue #54379.
Summary of the issue:
A UI implementation of a workaround that seeks to prevent duplicate runs of the same task instance by adding another confirmation pop-up before re-running tasks in a running, restarting, or up-for-retry state.
### What
---
The pop-up confirmation works by checking the state of the task instance when requesting a rerun. If the task instance is in a running, restarting, or up-for-retry state, then it will display a second confirmation pop-up. Otherwise, it will not show the second pop-up confirmation dialog.
**Here is a sample of the modal confirmation dialog when a task is running**:
https://github.com/user-attachments/assets/14759713-6354-4f7c-aa59-6d64fb00a859
**Here is a sample where the modal will not display when trying to re-run a task in other states other than running, restarting, and up-for-retry**:
https://github.com/user-attachments/assets/9a7332b7-5a5c-4f59-9447-c6ffa14e02f0
**Here is another, longer sample that simulates 2 users trying to re-run the same task**:
https://github.com/user-attachments/assets/f739aa70-5e8f-4a0b-b2ea-253287cd3fd1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2394480150
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -217,13 +218,22 @@ def clear_task_instances(
from airflow.models.dagbag import DBDagBag
scheduler_dagbag = DBDagBag(load_op_links=False)
+ task_confirmed_running = False
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
+
+ if prevent_running_task:
+ # If the task contains the message, prevent the task from running.
+ task_confirmed_running = True
+
if ti.state == TaskInstanceState.RUNNING:
+ if task_confirmed_running:
Review Comment:
```suggestion
if prevent_running_task:
```
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -217,13 +218,22 @@ def clear_task_instances(
from airflow.models.dagbag import DBDagBag
scheduler_dagbag = DBDagBag(load_op_links=False)
+ task_confirmed_running = False
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
+
+ if prevent_running_task:
+ # If the task contains the message, prevent the task from running.
+ task_confirmed_running = True
+
if ti.state == TaskInstanceState.RUNNING:
+ if task_confirmed_running:
+ raise ValueError(f"Error: Task {ti.task_id} is running, stopping attempt to run.")
# If a task is cleared when running, set its state to RESTARTING so that
# the task is terminated and becomes eligible for retry.
Review Comment:
move comment inside the `else`
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -770,12 +772,16 @@ def post_clear_task_instances(
)
if not dry_run:
- clear_task_instances(
- task_instances,
- session,
- DagRunState.QUEUED if reset_dag_runs else False,
- run_on_latest_version=body.run_on_latest_version,
- )
+ try:
+ clear_task_instances(
+ task_instances,
+ session,
+ DagRunState.QUEUED if reset_dag_runs else False,
+ run_on_latest_version=body.run_on_latest_version,
+ prevent_running_task=body.prevent_running_task,
+ )
+ except ValueError as e:
+ raise HTTPException(status.HTTP_400_BAD_REQUEST, str(e)) from e
Review Comment:
That pattern is ok but we should either:
- Check the 'message' for the ValueError. We only want this to handle `ValueError` caused by the `prevent_running_task` behavior. Other unexpected ValueError, shouldn't fall into 400 user errors.
- Change the exception raised there, maybe to raise a custom Exception such as `ClearRunningTaskException` or something like that, so you can catch it be sure not to interfer with other exceptions handling.
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -217,13 +218,22 @@ def clear_task_instances(
from airflow.models.dagbag import DBDagBag
scheduler_dagbag = DBDagBag(load_op_links=False)
+ task_confirmed_running = False
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
+
+ if prevent_running_task:
+ # If the task contains the message, prevent the task from running.
+ task_confirmed_running = True
+
Review Comment:
I don't understand this.
(It is inside the `tis` loop but doesn't actually depend on the ti at hand)
Also you probably don't need another variable. Just use `prevent_running_task` directly
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -217,13 +218,22 @@ def clear_task_instances(
from airflow.models.dagbag import DBDagBag
scheduler_dagbag = DBDagBag(load_op_links=False)
+ task_confirmed_running = False
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
+
+ if prevent_running_task:
+ # If the task contains the message, prevent the task from running.
+ task_confirmed_running = True
+
if ti.state == TaskInstanceState.RUNNING:
+ if task_confirmed_running:
+ raise ValueError(f"Error: Task {ti.task_id} is running, stopping attempt to run.")
Review Comment:
```suggestion
raise ValueError(f"Error: Task {ti.task_id} is running, stopping attempt to clear.")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org>.
KlarenceNicolasCatalan commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2396378655
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -217,13 +218,22 @@ def clear_task_instances(
from airflow.models.dagbag import DBDagBag
scheduler_dagbag = DBDagBag(load_op_links=False)
+ task_confirmed_running = False
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
+
+ if prevent_running_task:
+ # If the task contains the message, prevent the task from running.
+ task_confirmed_running = True
+
if ti.state == TaskInstanceState.RUNNING:
+ if task_confirmed_running:
Review Comment:
At first the restarting and up_for_retry were included as the check was done in the UI, but after moving it in the backend and discovered that there is already an existing check in `taskinstance.py`, so I left the check as it is (checking only if task is in running state).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #55660:
URL: https://github.com/apache/airflow/pull/55660#issuecomment-3387012812
So should we close this PR in favor of the other one?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2394500036
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -217,13 +218,22 @@ def clear_task_instances(
from airflow.models.dagbag import DBDagBag
scheduler_dagbag = DBDagBag(load_op_links=False)
+ task_confirmed_running = False
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
+
+ if prevent_running_task:
+ # If the task contains the message, prevent the task from running.
+ task_confirmed_running = True
+
if ti.state == TaskInstanceState.RUNNING:
+ if task_confirmed_running:
Review Comment:
Also PR description also mention (scheduled and up_for_retry), but we seem to only handle `RUNNING` states) there, is that expected?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2396942641
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -79,13 +79,16 @@
)
from airflow.api_fastapi.logging.decorators import action_logging
from airflow.exceptions import TaskNotFound
+from airflow.exceptions import AirflowClearRunningTaskException
from airflow.models import Base, DagRun
from airflow.models.taskinstance import TaskInstance as TI, clear_task_instances
from airflow.models.taskinstancehistory import TaskInstanceHistory as TIH
from airflow.ti_deps.dep_context import DepContext
from airflow.ti_deps.dependencies_deps import SCHEDULER_QUEUED_DEPS
from airflow.utils.db import get_query_count
from airflow.utils.state import DagRunState, TaskInstanceState
+from flask import jsonify
+from airflow.configuration import conf
Review Comment:
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #55660:
URL: https://github.com/apache/airflow/pull/55660#issuecomment-3290490635
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
- In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
- Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
Apache Airflow is a community-driven project and together we are making it better 🚀.
In case of doubts contact the developers at:
Mailing List: dev@airflow.apache.org
Slack: https://s.apache.org/airflow-slack
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun closed pull request #55660: Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states.
URL: https://github.com/apache/airflow/pull/55660
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on PR #55660:
URL: https://github.com/apache/airflow/pull/55660#issuecomment-3401873506
Closing as requested @KlarenceNicolasCatalan
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2362153068
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -215,12 +215,22 @@ def clear_task_instances(
"""
task_instance_ids: list[str] = []
from airflow.models.dagbag import DBDagBag
+ from fastapi import HTTPException
scheduler_dagbag = DBDagBag(load_op_links=False)
+ isRunning = False
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
+ if hasattr(ti, 'is_running_message') and ti.is_running_message == True:
+ isRunning = True
Review Comment:
Naming is really difficult, but it seems there will be better naming for the `isRunning` logic here.
Since the purpose of `is_running_message` is more like `confirm_clear_running` or `allow_clear_running_task` ... etc.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -770,6 +770,9 @@ def post_clear_task_instances(
)
if not dry_run:
+ if hasattr(body, 'is_running_message'):
Review Comment:
The `body` is already a Pydantic schema. Would it be better to access the attribute directly?
```suggestion
if body.is_running_message:
```
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -215,12 +215,22 @@ def clear_task_instances(
"""
task_instance_ids: list[str] = []
from airflow.models.dagbag import DBDagBag
+ from fastapi import HTTPException
scheduler_dagbag = DBDagBag(load_op_links=False)
+ isRunning = False
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
+ if hasattr(ti, 'is_running_message') and ti.is_running_message == True:
+ isRunning = True
+
if ti.state == TaskInstanceState.RUNNING:
+ if isRunning == True:
+ raise HTTPException(
+ status_code=400,
+ detail=f"Task {ti.task_id} is running, restarting"
+ )
Review Comment:
We should not raise FastAPI `HTTPException` in the model level, because it will couple FastAPI with Airflow Core.
It would be better to raise `ValueError` in model, and the router can catch `ValueError` and raise it as `HTTPException`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org>.
KlarenceNicolasCatalan commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2386439485
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -770,12 +770,19 @@ def post_clear_task_instances(
)
if not dry_run:
- clear_task_instances(
- task_instances,
- session,
- DagRunState.QUEUED if reset_dag_runs else False,
- run_on_latest_version=body.run_on_latest_version,
- )
+ if body.is_running_message:
+ for ti in task_instances:
+ ti.is_running_message = body.is_running_message
+
+ try:
+ clear_task_instances(
+ task_instances,
+ session,
+ DagRunState.QUEUED if reset_dag_runs else False,
+ run_on_latest_version=body.run_on_latest_version,
+ )
+ except ValueError as e:
Review Comment:
Hello, thanks for the comment!
I added an if conditional in taskInstance.py to raise a ValueError and stop another clearTaskInstance from running. This way, it prevents starting a task that’s already running and raises a Bad Request exception in task_instances. Does this approach cause more issues, or is the error code not the right one to use?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2355428665
##########
airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceConfirmationDialog.tsx:
##########
@@ -0,0 +1,102 @@
+import { VStack } from "@chakra-ui/react";
+
+import { Button, Dialog } from "src/components/ui";
+import { useClearTaskInstancesDryRun } from "src/queries/useClearTaskInstancesDryRun";
+import { getRelativeTime } from "src/utils/datetimeUtils";
+
+type Props = {
+ readonly onClose: () => void;
+ readonly onConfirm?: () => void;
+ readonly open: boolean;
+ readonly dagDetails?: {
+ dagId: string;
+ dagRunId: string;
+ taskId: string;
+ mapIndex?: number;
+ downstream?: boolean;
+ future?: boolean;
+ past?: boolean;
+ upstream?: boolean;
+ onlyFailed?: boolean;
+ };
+};
+
+const ClearTaskInstanceConfirmationDialog = ({ onClose, open, onConfirm, dagDetails }: Props) => {
+ const { data, isFetching } = useClearTaskInstancesDryRun({
+ dagId: dagDetails?.dagId || "",
+ options: {
+ enabled: open && !!dagDetails,
+ refetchOnMount: "always",
+ refetchOnWindowFocus: false,
+ staleTime: 0,
+ gcTime: 0,
+ },
+ requestBody: {
+ dag_run_id: dagDetails?.dagRunId,
+ include_downstream: dagDetails?.downstream,
+ include_future: dagDetails?.future,
+ include_past: dagDetails?.past,
+ include_upstream: dagDetails?.upstream,
+ only_failed: dagDetails?.onlyFailed,
+ task_ids: [[dagDetails?.taskId || "", dagDetails?.mapIndex || 0]],
+ },
+ });
+
+ // Shared confirm handler to reduce duplication
+ const handleConfirm = () => {
+ if (onConfirm) {
+ onConfirm();
+ }
+ onClose();
+ };
+
+ if (isFetching) {
+ return null;
+ }
+
+ // Dialog will only open if the task is in a 'running' state
+ // Added up-for-retry and restarting
+ const taskCurrentState = !isFetching && data && data.task_instances?.[0]?.state
+ if (taskCurrentState != "running" && taskCurrentState != "restarting" && taskCurrentState != "up_for_retry") {
+ handleConfirm();
+ return null;
+ }
+
+ return (
+ <Dialog.Root lazyMount onOpenChange={onClose} open={open}>
+ <Dialog.Content backdrop>
+ <Dialog.Header>
+ <VStack align={"start"} gap={4}>
+ <Dialog.Title>Confirm Clear Task Instance</Dialog.Title>
+ <Dialog.Description>
+ {data?.task_instances?.[0] && (
+ <>
+ This task instance was last run by{" "}
+ <strong>{data.task_instances[0].unixname || "unknown user"}</strong>{" "}
+ {data.task_instances[0].start_date && (
+ <>starting {getRelativeTime(data.task_instances[0].start_date)}</>
+ )}
+ {data.task_instances[0].end_date && data.task_instances[0].state === "success" && (
+ <> and completed {getRelativeTime(data.task_instances[0].end_date)}</>
+ )}
+ . The task is currently <strong>{data.task_instances[0].state || "unknown"}</strong>. Are
+ you sure you want to clear it again?
Review Comment:
Translation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org>.
KlarenceNicolasCatalan commented on PR #55660:
URL: https://github.com/apache/airflow/pull/55660#issuecomment-3400353608
> So should we close this PR in favor of the other one?
If possible, yes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org>.
KlarenceNicolasCatalan commented on PR #55660:
URL: https://github.com/apache/airflow/pull/55660#issuecomment-3363828028
Hello,
This comment will be an update for this PR
**This is how the PR currently looks like**:
https://github.com/user-attachments/assets/9e3281f3-61ac-40c9-9c7e-11cf01b717c3
Since the current state of this PR is a little bit different from the expected outcome stated in the PR description, I will make a new PR that uses this PR's code. The will be new PR's goal will still be the same however in the description, instead of a modal pop-up, it will be a checkbox instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on PR #55660:
URL: https://github.com/apache/airflow/pull/55660#issuecomment-3302872984
Also we should probably do something similar for Runs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2370730952
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -770,12 +770,19 @@ def post_clear_task_instances(
)
if not dry_run:
- clear_task_instances(
- task_instances,
- session,
- DagRunState.QUEUED if reset_dag_runs else False,
- run_on_latest_version=body.run_on_latest_version,
- )
+ if body.is_running_message:
+ for ti in task_instances:
+ ti.is_running_message = body.is_running_message
+
+ try:
+ clear_task_instances(
+ task_instances,
+ session,
+ DagRunState.QUEUED if reset_dag_runs else False,
+ run_on_latest_version=body.run_on_latest_version,
+ )
+ except ValueError as e:
+ raise HTTPException(status.HTTP_400_BAD_REQUEST, str(e)) from e
Review Comment:
Thanks for the update! We should add 400 status code to line 688 HTTP exception as well. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2382417076
##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/task_instances.py:
##########
@@ -202,6 +202,7 @@ class ClearTaskInstancesBody(StrictBaseModel):
description="(Experimental) Run on the latest bundle version of the dag after "
"clearing the task instances.",
)
+ is_running_message: bool = False
Review Comment:
We should probably change the naming here. "force", "force_running", "bypass_running" or something else, `message` makes me think of a 'string'
##########
airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.tsx:
##########
@@ -170,6 +171,14 @@ const ClearTaskInstanceDialog = ({ onClose, open, taskInstance }: Props) => {
{translate("dags:runAndTaskActions.options.runOnLatestVersion")}
</Checkbox>
) : undefined}
+ <Checkbox
+ checked={isRunningMessage}
+ style={{ marginRight: "auto"}}
+ onCheckedChange={(event) => setIsRunningMessage(Boolean(event.checked))}
+ >
+ {/* Will need approval for translation changes, please remember */}
+ {translate("dags:runAndTaskActions.options.preventRunningTasks")}
Review Comment:
you can remove this comment, it's fine this is for 3.1+, freeze will be gone.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -770,12 +770,19 @@ def post_clear_task_instances(
)
if not dry_run:
- clear_task_instances(
- task_instances,
- session,
- DagRunState.QUEUED if reset_dag_runs else False,
- run_on_latest_version=body.run_on_latest_version,
- )
+ if body.is_running_message:
+ for ti in task_instances:
+ ti.is_running_message = body.is_running_message
Review Comment:
dynamically adding an attribute to the ti model like this is not recommended.
You just need to pass down the `force` param to `clear_task_instances` and handle there what to do.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -770,12 +770,19 @@ def post_clear_task_instances(
)
if not dry_run:
- clear_task_instances(
- task_instances,
- session,
- DagRunState.QUEUED if reset_dag_runs else False,
- run_on_latest_version=body.run_on_latest_version,
- )
+ if body.is_running_message:
+ for ti in task_instances:
+ ti.is_running_message = body.is_running_message
+
+ try:
+ clear_task_instances(
+ task_instances,
+ session,
+ DagRunState.QUEUED if reset_dag_runs else False,
+ run_on_latest_version=body.run_on_latest_version,
+ )
+ except ValueError as e:
Review Comment:
did you encountered an unhandled ValueError? Those should crash the server if they are unexpected. (only throw 400 if this is actually client's falt)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2382433185
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -215,12 +215,22 @@ def clear_task_instances(
"""
task_instance_ids: list[str] = []
from airflow.models.dagbag import DBDagBag
+ from fastapi import HTTPException
scheduler_dagbag = DBDagBag(load_op_links=False)
+ isRunning = False
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
+ if hasattr(ti, 'is_running_message') and ti.is_running_message == True:
+ isRunning = True
Review Comment:
I agree, also the `isRunning` should be `is_running`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Modal Confirmation Dialog before rerun of tasks in 'Running', 'Restarting', and 'Up_for_retry' states. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #55660:
URL: https://github.com/apache/airflow/pull/55660#issuecomment-3293938203
The backend should return an error on an erroneous second clear action. Let's not do a UI-only bandaid solution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org