Skip to content

Commit b9ab634

Browse files
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.
1 parent 8686c89 commit b9ab634

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

airflow/ui/src/pages/MappedTaskInstance/Header.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ export const Header = ({
4646
...entries,
4747
{ label: "Start", value: <Time datetime={taskInstance.start_date} /> },
4848
{ label: "End", value: <Time datetime={taskInstance.end_date} /> },
49-
{ label: "Duration", value: `${getDuration(taskInstance.start_date, taskInstance.end_date)}s` },
49+
...(Boolean(taskInstance.start_date)
50+
? [{ label: "Duration", value: `${getDuration(taskInstance.start_date, taskInstance.end_date)}s` }]
51+
: []),
5052
];
5153

5254
return (

airflow/ui/src/pages/TaskInstance/Details.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,9 @@ export const Details = () => {
134134
<Table.Row>
135135
<Table.Cell>Duration</Table.Cell>
136136
<Table.Cell>
137-
{
138-
// eslint-disable-next-line unicorn/no-null
139-
getDuration(tryInstance?.start_date ?? null, tryInstance?.end_date ?? null)
140-
}
141-
s
137+
{Boolean(tryInstance?.start_date) // eslint-disable-next-line unicorn/no-null
138+
? `${getDuration(tryInstance?.start_date ?? null, tryInstance?.end_date ?? null)}s`
139+
: ""}
142140
</Table.Cell>
143141
</Table.Row>
144142
<Table.Row>

airflow/ui/src/pages/TaskInstance/Header.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ export const Header = ({
4646
...(taskInstance.try_number > 1 ? [{ label: "Try Number", value: taskInstance.try_number }] : []),
4747
{ label: "Start", value: <Time datetime={taskInstance.start_date} /> },
4848
{ label: "End", value: <Time datetime={taskInstance.end_date} /> },
49-
{ label: "Duration", value: `${getDuration(taskInstance.start_date, taskInstance.end_date)}s` },
49+
...(Boolean(taskInstance.start_date)
50+
? [{ label: "Duration", value: `${getDuration(taskInstance.start_date, taskInstance.end_date)}s` }]
51+
: []),
5052
{
5153
label: "DAG Version",
5254
value:

airflow/ui/src/pages/TaskInstances/TaskInstances.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ const taskInstanceColumns = (
137137
header: "Operator",
138138
},
139139
{
140-
cell: ({ row: { original } }) => `${getDuration(original.start_date, original.end_date)}s`,
140+
cell: ({ row: { original } }) =>
141+
Boolean(original.start_date) ? `${getDuration(original.start_date, original.end_date)}s` : "",
141142
header: "Duration",
142143
},
143144
{

0 commit comments

Comments
 (0)