This is an automated email from the ASF dual-hosted git repository.
jedcunningham pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new b9ab6342114 Hide task duration if we don't have a start_date (#47633)
b9ab6342114 is described below
commit b9ab6342114c21df5d378455a3d3171b1cfa326d
Author: Jed Cunningham <[email protected]>
AuthorDate: Tue Mar 11 14:44:43 2025 -0600
Hide task duration if we don't have a start_date (#47633)
In some failure scenarios, we can have an end_date without a start_date.
If we naively show a duration in these cases, we end up with a negative
duration, which isn't ideal. This hides the duration if we don't have
start_date.
End_date wasn't added to the condition so a duration is still shown for
running tasks - those with a start_date but no end_date.
---
airflow/ui/src/pages/MappedTaskInstance/Header.tsx | 4 +++-
airflow/ui/src/pages/TaskInstance/Details.tsx | 8 +++-----
airflow/ui/src/pages/TaskInstance/Header.tsx | 4 +++-
airflow/ui/src/pages/TaskInstances/TaskInstances.tsx | 3 ++-
4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/airflow/ui/src/pages/MappedTaskInstance/Header.tsx
b/airflow/ui/src/pages/MappedTaskInstance/Header.tsx
index 9396802a2d8..edf389805f0 100644
--- a/airflow/ui/src/pages/MappedTaskInstance/Header.tsx
+++ b/airflow/ui/src/pages/MappedTaskInstance/Header.tsx
@@ -46,7 +46,9 @@ export const Header = ({
...entries,
{ label: "Start", value: <Time datetime={taskInstance.start_date} /> },
{ label: "End", value: <Time datetime={taskInstance.end_date} /> },
- { label: "Duration", value: `${getDuration(taskInstance.start_date,
taskInstance.end_date)}s` },
+ ...(Boolean(taskInstance.start_date)
+ ? [{ label: "Duration", value: `${getDuration(taskInstance.start_date,
taskInstance.end_date)}s` }]
+ : []),
];
return (
diff --git a/airflow/ui/src/pages/TaskInstance/Details.tsx
b/airflow/ui/src/pages/TaskInstance/Details.tsx
index 550120a1641..a97675b2f4d 100644
--- a/airflow/ui/src/pages/TaskInstance/Details.tsx
+++ b/airflow/ui/src/pages/TaskInstance/Details.tsx
@@ -134,11 +134,9 @@ export const Details = () => {
<Table.Row>
<Table.Cell>Duration</Table.Cell>
<Table.Cell>
- {
- // eslint-disable-next-line unicorn/no-null
- getDuration(tryInstance?.start_date ?? null,
tryInstance?.end_date ?? null)
- }
- s
+ {Boolean(tryInstance?.start_date) // eslint-disable-next-line
unicorn/no-null
+ ? `${getDuration(tryInstance?.start_date ?? null,
tryInstance?.end_date ?? null)}s`
+ : ""}
</Table.Cell>
</Table.Row>
<Table.Row>
diff --git a/airflow/ui/src/pages/TaskInstance/Header.tsx
b/airflow/ui/src/pages/TaskInstance/Header.tsx
index 9d47ba6323b..b8fe1602ca4 100644
--- a/airflow/ui/src/pages/TaskInstance/Header.tsx
+++ b/airflow/ui/src/pages/TaskInstance/Header.tsx
@@ -46,7 +46,9 @@ export const Header = ({
...(taskInstance.try_number > 1 ? [{ label: "Try Number", value:
taskInstance.try_number }] : []),
{ label: "Start", value: <Time datetime={taskInstance.start_date} /> },
{ label: "End", value: <Time datetime={taskInstance.end_date} /> },
- { label: "Duration", value: `${getDuration(taskInstance.start_date,
taskInstance.end_date)}s` },
+ ...(Boolean(taskInstance.start_date)
+ ? [{ label: "Duration", value: `${getDuration(taskInstance.start_date,
taskInstance.end_date)}s` }]
+ : []),
{
label: "DAG Version",
value:
diff --git a/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx
b/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx
index 82e08ce9b31..cd0d6192ccb 100644
--- a/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx
+++ b/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx
@@ -137,7 +137,8 @@ const taskInstanceColumns = (
header: "Operator",
},
{
- cell: ({ row: { original } }) => `${getDuration(original.start_date,
original.end_date)}s`,
+ cell: ({ row: { original } }) =>
+ Boolean(original.start_date) ? `${getDuration(original.start_date,
original.end_date)}s` : "",
header: "Duration",
},
{