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


##########
providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py:
##########
@@ -56,6 +66,130 @@
     )
 
 
+class _CloudWatchLogHandler(watchtower.CloudWatchLogHandler):
+    """
+    watchtower's handler, which can also flush a single stream, and doesn't 
wait on a stream still being created.
+
+    watchtower's ``flush`` and ``close`` wait up to ``FLUSH_TIMEOUT`` on each 
stream in turn, also on one whose
+    sender is retrying CreateLogStream in ``creator``, and fail when another 
thread opens a stream meanwhile.
+    """
+
+    NUDGE_S = 5.0
+    creator: _LogStreamCreator | None = None
+    _nudged_at = float("-inf")
+
+    def flush(self) -> None:
+        if not self.shutting_down:
+            self._send_queued(list(self.queues.items()), self.FLUSH)
+
+    def close(self) -> None:

Review Comment:
   nit: watchtower's own `close()` warns "Timed out while delivering logs" when 
a queue still holds records after the wait. This override drops that, and it 
now skips streams still being created on purpose, so lines lost at shutdown go 
unreported. Could we keep a warning for queues that aren't empty here?



##########
providers/amazon/docs/logging/cloud-watch-task-handlers.rst:
##########
@@ -36,3 +36,19 @@ To enable this feature, ``airflow.cfg`` must be configured 
as follows:
     remote_log_conn_id = MyCloudwatchConn
 
 In the above example, Airflow will try to use 
``AwsLogsHook('MyCloudwatchConn')``.
+
+Reading logs needs the ``logs:DescribeLogStreams`` permission on the log 
group, besides ``logs:GetLogEvents``.
+The trigger of a deferred task writes to its own log stream, and Airflow finds 
it by listing the streams that
+start with the task's log name. Without the permission, Airflow reads the 
task's own stream alone.
+
+On Airflow versions that write asset watcher logs, a watcher's logs go under 
``triggers/trigger_id=<id>/``.

Review Comment:
   nit: "On Airflow versions that write asset watcher logs" is hard to act on 
for a reader. Could this name the version, e.g. "From Airflow 3.5.0" (assuming 
#76527 ships there)?



-- 
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