This is an automated email from the ASF dual-hosted git repository.

bbovenzi 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 254a0d7dc6 Change DAG Audit log tab to Event Log (#40967)
254a0d7dc6 is described below

commit 254a0d7dc60c47e248bbbca547a24cdc41b494a8
Author: Brent Bovenzi <[email protected]>
AuthorDate: Wed Jul 24 08:15:14 2024 -0400

    Change DAG Audit log tab to Event Log (#40967)
    
    * Change Audit Log to Event Log
    
    * Disable sortby map index and try number
    
    * Rename tab url name
---
 airflow/api_connexion/openapi/v1.yaml              | 13 ++++++++-
 .../www/static/js/components/NewTable/NewCells.tsx |  7 +++--
 .../js/dag/details/{AuditLog.tsx => EventLog.tsx}  | 32 +++++++++++++++++-----
 airflow/www/static/js/dag/details/index.tsx        | 14 ++++++----
 .../js/dag/details/taskInstance/Logs/index.tsx     | 18 +++++++++++-
 airflow/www/static/js/types/api-generated.ts       |  7 ++++-
 6 files changed, 73 insertions(+), 18 deletions(-)

diff --git a/airflow/api_connexion/openapi/v1.yaml 
b/airflow/api_connexion/openapi/v1.yaml
index 14d1788045..ed98e5c0d8 100644
--- a/airflow/api_connexion/openapi/v1.yaml
+++ b/airflow/api_connexion/openapi/v1.yaml
@@ -3430,6 +3430,16 @@ components:
           type: string
           readOnly: true
           nullable: true
+        map_index:
+          description: The Map Index
+          type: integer
+          readOnly: true
+          nullable: true
+        try_number:
+          description: The Try Number
+          type: integer
+          readOnly: true
+          nullable: true
         event:
           description: A key describing the type of event.
           type: string
@@ -3459,6 +3469,7 @@ components:
         Collection of event logs.
 
         *Changed in version 2.1.0*&#58; 'total_entries' field is added.
+        *Changed in version 2.10.0*&#58; 'try_number' and 'map_index' fields 
are added.
       allOf:
         - type: object
           properties:
@@ -3487,7 +3498,7 @@ components:
         stack_trace:
           type: string
           readOnly: true
-          description: The full stackstrace..
+          description: The full stackstrace.
 
     ImportErrorCollection:
       type: object
diff --git a/airflow/www/static/js/components/NewTable/NewCells.tsx 
b/airflow/www/static/js/components/NewTable/NewCells.tsx
index 9be1b88741..b6c67f95ab 100644
--- a/airflow/www/static/js/components/NewTable/NewCells.tsx
+++ b/airflow/www/static/js/components/NewTable/NewCells.tsx
@@ -19,15 +19,18 @@
 
 import React from "react";
 import { Code } from "@chakra-ui/react";
+import type { CellContext } from "@tanstack/react-table";
 
 import Time from "src/components/Time";
 
-export const TimeCell = ({ getValue }: any) => {
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export const TimeCell = ({ getValue }: CellContext<any, any>) => {
   const value = getValue();
   return <Time dateTime={value} />;
 };
 
-export const CodeCell = ({ getValue }: any) => {
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export const CodeCell = ({ getValue }: CellContext<any, any>) => {
   const value = getValue();
   return value ? <Code>{value}</Code> : null;
 };
diff --git a/airflow/www/static/js/dag/details/AuditLog.tsx 
b/airflow/www/static/js/dag/details/EventLog.tsx
similarity index 90%
rename from airflow/www/static/js/dag/details/AuditLog.tsx
rename to airflow/www/static/js/dag/details/EventLog.tsx
index 3436d397e1..735a193e3f 100644
--- a/airflow/www/static/js/dag/details/AuditLog.tsx
+++ b/airflow/www/static/js/dag/details/EventLog.tsx
@@ -46,7 +46,7 @@ import { useEventLogs } from "src/api";
 import { getMetaValue, useOffsetTop } from "src/utils";
 import type { DagRun } from "src/types";
 import LinkButton from "src/components/LinkButton";
-import type { EventLog } from "src/types/api-generated";
+import type { EventLog as EventLogType } from "src/types/api-generated";
 import { NewTable } from "src/components/NewTable/NewTable";
 import { useTableURLState } from "src/components/NewTable/useTableUrlState";
 import { CodeCell, TimeCell } from "src/components/NewTable/NewCells";
@@ -60,6 +60,7 @@ const configIncludedEvents = 
getMetaValue("included_audit_log_events");
 
 interface Props {
   taskId?: string;
+  showMapped?: boolean;
   run?: DagRun;
 }
 
@@ -70,9 +71,9 @@ interface Option extends OptionBase {
 
 const dagId = getMetaValue("dag_id") || undefined;
 
-const columnHelper = createColumnHelper<EventLog>();
+const columnHelper = createColumnHelper<EventLogType>();
 
-const AuditLog = ({ taskId, run }: Props) => {
+const EventLog = ({ taskId, run, showMapped }: Props) => {
   const logRef = useRef<HTMLDivElement>(null);
   const offsetTop = useOffsetTop(logRef);
   const { tableURLState, setTableURLState } = useTableURLState({
@@ -138,7 +139,23 @@ const AuditLog = ({ taskId, run }: Props) => {
     const runId = columnHelper.accessor("runId", {
       header: "Run Id",
     });
+
+    const mapIndex = columnHelper.accessor("mapIndex", {
+      header: "Map Index",
+      enableSorting: false,
+      meta: {
+        skeletonWidth: 10,
+      },
+      cell: (props) => (props.getValue() === -1 ? undefined : 
props.getValue()),
+    });
     const rest = [
+      columnHelper.accessor("tryNumber", {
+        header: "Try Number",
+        enableSorting: false,
+        meta: {
+          skeletonWidth: 10,
+        },
+      }),
       columnHelper.accessor("event", {
         header: "Event",
         meta: {
@@ -146,13 +163,13 @@ const AuditLog = ({ taskId, run }: Props) => {
         },
       }),
       columnHelper.accessor("owner", {
-        header: "Owner",
+        header: "User",
         meta: {
           skeletonWidth: 20,
         },
       }),
       columnHelper.accessor("extra", {
-        header: "Extra",
+        header: "Details",
         cell: CodeCell,
       }),
     ];
@@ -160,9 +177,10 @@ const AuditLog = ({ taskId, run }: Props) => {
       when,
       ...(!run ? [runId] : []),
       ...(!taskId ? [task] : []),
+      ...(showMapped ? [mapIndex] : []),
       ...rest,
     ];
-  }, [taskId, run]);
+  }, [taskId, run, showMapped]);
 
   const memoData = useMemo(() => data?.eventLogs, [data?.eventLogs]);
 
@@ -262,4 +280,4 @@ const AuditLog = ({ taskId, run }: Props) => {
   );
 };
 
-export default AuditLog;
+export default EventLog;
diff --git a/airflow/www/static/js/dag/details/index.tsx 
b/airflow/www/static/js/dag/details/index.tsx
index c76744df07..afced331f0 100644
--- a/airflow/www/static/js/dag/details/index.tsx
+++ b/airflow/www/static/js/dag/details/index.tsx
@@ -42,8 +42,8 @@ import {
   MdOutlineViewTimeline,
   MdSyncAlt,
   MdHourglassBottom,
-  MdPlagiarism,
   MdEvent,
+  MdOutlineEventNote,
 } from "react-icons/md";
 import { BiBracket, BiLogoKubernetes } from "react-icons/bi";
 import URLSearchParamsWrapper from "src/utils/URLSearchParamWrapper";
@@ -65,7 +65,7 @@ import ClearInstance from 
"./taskInstance/taskActions/ClearInstance";
 import MarkInstanceAs from "./taskInstance/taskActions/MarkInstanceAs";
 import XcomCollection from "./taskInstance/Xcom";
 import TaskDetails from "./task";
-import AuditLog from "./AuditLog";
+import EventLog from "./EventLog";
 import RunDuration from "./dag/RunDuration";
 import Calendar from "./dag/Calendar";
 import RenderedK8s from "./taskInstance/RenderedK8s";
@@ -90,6 +90,7 @@ const tabToIndex = (tab?: string) => {
       return 2;
     case "code":
       return 3;
+    case "event_log":
     case "audit_log":
       return 4;
     case "logs":
@@ -130,7 +131,7 @@ const indexToTab = (
     case 3:
       return "code";
     case 4:
-      return "audit_log";
+      return "event_log";
     case 5:
       if (isMappedTaskSummary) return "mapped_tasks";
       if (isTaskInstance) return "logs";
@@ -323,9 +324,9 @@ const Details = ({
             </Text>
           </Tab>
           <Tab>
-            <MdPlagiarism size={16} />
+            <MdOutlineEventNote size={16} />
             <Text as="strong" ml={1}>
-              Audit Log
+              Event Log
             </Text>
           </Tab>
           {isDag && (
@@ -438,8 +439,9 @@ const Details = ({
             <DagCode />
           </TabPanel>
           <TabPanel height="100%">
-            <AuditLog
+            <EventLog
               taskId={isGroup || !taskId ? undefined : taskId}
+              showMapped={isMapped || !taskId}
               run={run}
             />
           </TabPanel>
diff --git a/airflow/www/static/js/dag/details/taskInstance/Logs/index.tsx 
b/airflow/www/static/js/dag/details/taskInstance/Logs/index.tsx
index ef5068545a..a9bdf743d5 100644
--- a/airflow/www/static/js/dag/details/taskInstance/Logs/index.tsx
+++ b/airflow/www/static/js/dag/details/taskInstance/Logs/index.tsx
@@ -19,7 +19,7 @@
 
 import React, { useState, useEffect, useMemo } from "react";
 import { Text, Box, Flex, Checkbox, Icon, Spinner } from "@chakra-ui/react";
-import { MdWarning } from "react-icons/md";
+import { MdInfo, MdWarning } from "react-icons/md";
 
 import { getMetaValue } from "src/utils";
 import useTaskLog from "src/api/useTaskLog";
@@ -248,11 +248,27 @@ const Logs = ({
           borderColor="gray.400"
           alignItems="center"
           p={2}
+          mb={2}
         >
           <Icon as={MdWarning} color="yellow.500" mr={2} />
           <Text fontSize="sm">{warning}</Text>
         </Flex>
       )}
+      {(!data || !parsedLogs) && !isLoading && (
+        <Flex
+          bg="blue.100"
+          borderRadius={2}
+          borderColor="gray.400"
+          alignItems="center"
+          p={2}
+          mb={2}
+        >
+          <Icon as={MdInfo} color="blue.600" mr={2} />
+          <Text fontSize="sm">
+            No task logs found. Try the Event Log tab for more context.
+          </Text>
+        </Flex>
+      )}
       {isLoading ? (
         <Spinner />
       ) : (
diff --git a/airflow/www/static/js/types/api-generated.ts 
b/airflow/www/static/js/types/api-generated.ts
index e7b37e2714..6ec7e3d1ff 100644
--- a/airflow/www/static/js/types/api-generated.ts
+++ b/airflow/www/static/js/types/api-generated.ts
@@ -1284,6 +1284,10 @@ export interface components {
       task_id?: string | null;
       /** @description The DAG Run ID */
       run_id?: string | null;
+      /** @description The Map Index */
+      map_index?: number | null;
+      /** @description The Try Number */
+      try_number?: number | null;
       /** @description A key describing the type of event. */
       event?: string;
       /**
@@ -1300,6 +1304,7 @@ export interface components {
      * @description Collection of event logs.
      *
      * *Changed in version 2.1.0*&#58; 'total_entries' field is added.
+     * *Changed in version 2.10.0*&#58; 'try_number' and 'map_index' fields 
are added.
      */
     EventLogCollection: {
       event_logs?: components["schemas"]["EventLog"][];
@@ -1314,7 +1319,7 @@ export interface components {
       timestamp?: string;
       /** @description The filename */
       filename?: string;
-      /** @description The full stackstrace.. */
+      /** @description The full stackstrace. */
       stack_trace?: string;
     };
     /**

Reply via email to