ferruzzi commented on code in PR #70635:
URL: https://github.com/apache/airflow/pull/70635#discussion_r3668841147
##########
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:
+ try:
+ trigger_stream_names =
self.io._get_trigger_stream_names(stream_name)
Review Comment:
Calling a "private" method from another class is a code smell, should
`io._get_trigger_stream_names` be renamed to drop the leading underscore? It
also looks like a genuinely useful helper that may be reused elsewhere if it
wasn't private.
--
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]