o-nikolas commented on code in PR #76560:
URL: https://github.com/apache/airflow/pull/76560#discussion_r4648236616


##########
airflow-core/docs/security/api_permissions_ref.rst:
##########
@@ -598,6 +598,10 @@ source code so it stays up to date as endpoints are added 
or changed.
      - ``/api/v2/triggers/{trigger_id}``
      - ``DAG.TASK_INSTANCE or DAG.RUN or Asset``
      - ``GET``
+   * - ``GET``
+     - ``/api/v2/triggers/{trigger_id}/logs``
+     - ``DAG.TASK_INSTANCE or DAG.RUN or Asset``

Review Comment:
   This endpoint also needs `DAG.TASK_LOGS` on the owner's Dag (for a watcher: 
Asset read plus `DAG.TASK_LOGS` on a Dag scheduled on the asset), otherwise it 
returns 403. Could this row say so? As written, a role built from this table 
gets a 403 on the Logs tab.



##########
providers/fab/docs/auth-manager/access-control.rst:
##########
@@ -772,6 +772,10 @@ Stable API Permissions
      - GET
      - DAGs.can_read and DAG Runs.can_read and Task Instances.can_read, or 
DAGs.can_read and DAG Runs.can_read, or Assets.can_read
      - Viewer
+   * - ``/api/v2/triggers/{trigger_id}/logs``
+     - GET
+     - DAGs.can_read and DAG Runs.can_read and Task Instances.can_read, or 
DAGs.can_read and DAG Runs.can_read, or Assets.can_read

Review Comment:
   Same as in `api_permissions_ref.rst`: `Task Logs.can_read` is needed on top 
of these for the logs endpoint.



##########
airflow-core/src/airflow/ui/src/queries/useLogs.tsx:
##########
@@ -413,3 +417,30 @@ export const useCallbackLogs = ({ callbackId, dagId, 
dagRunId, ...displayOptions
 
   return { parsedData: { ...parsedData, searchableText }, ...rest, 
fetchedData: data };
 };
+
+type TriggerLogsProps = { triggerId: number } & Omit<
+  Props,
+  "accept" | "dagId" | "historical" | "limit" | "taskInstance" | "tryNumber"
+>;
+
+export const useTriggerLogs = ({ triggerId, ...displayOptions }: 
TriggerLogsProps) => {
+  const { t: translate } = useTranslation();
+  const refetchInterval = useAutoRefresh({});
+
+  // A live trigger keeps logging; stop on an error, such as the 404 once it 
has finished.
+  const { data, ...rest } = useTriggerServiceGetTriggerLogs(
+    { accept: "application/x-ndjson", triggerId },
+    undefined,
+    { refetchInterval: ({ state }) => state.status !== "error" && 
refetchInterval },

Review Comment:
   Bug +1 on this one. Refresh only while the trigger is running, and back off 
the way `useAutoRefresh` does when there are no pending runs (10x). On 
CloudWatch a quiet watcher's refresh can be 50-100 GetLogEvents calls every 3 s 
per open tab, on the same quota task log reads 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to