vincbeck commented on code in PR #70635:
URL: https://github.com/apache/airflow/pull/70635#discussion_r3668196711


##########
providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py:
##########
@@ -417,18 +474,37 @@ def _read_remote_logs(
         self, task_instance, try_number, metadata=None
     ) -> tuple[LogSourceInfo, LogMessages]:
         stream_name = self._render_filename(task_instance, try_number)
-        messages, logs = self.io.read(stream_name, task_instance)
 
         messages = [
             f"Reading remote log from Cloudwatch log_group: 
{self.io.log_group} log_stream: {stream_name}"
         ]
+        logs: LogMessages = []
         try:
             events = self.io.get_cloudwatch_logs(stream_name, task_instance)
-            logs = ["\n".join(self._event_to_str(event) for event in events)]
+            logs.append("\n".join(self._event_to_str(event) for event in 
events))
         except Exception as e:
-            logs = []
             messages.append(str(e))
 
+        # See CloudWatchRemoteLogIO.stream() for why deferred-task trigger 
logs need a
+        # separate lookup -- the same gap applies to this (legacy) handler 
class.
+        if getattr(task_instance, "state", None) != TaskInstanceState.DEFERRED:

Review Comment:
   This code looks very similar to the block above, any chance to factorize?



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