vandonr-amz commented on code in PR #29522:
URL: https://github.com/apache/airflow/pull/29522#discussion_r1151010904


##########
airflow/providers/amazon/aws/hooks/batch_client.py:
##########
@@ -419,8 +419,46 @@ def get_job_awslogs_info(self, job_id: str) -> dict[str, 
str] | None:
 
         :param job_id: AWS Batch Job ID
         """
-        job_container_desc = 
self.get_job_description(job_id=job_id).get("container", {})
-        log_configuration = job_container_desc.get("logConfiguration", {})
+        job_desc = self.get_job_description(job_id=job_id)
+
+        job_node_properties = job_desc.get("nodeProperties", {})
+        job_container_desc = job_desc.get("container", {})
+
+        if job_node_properties:
+            job_node_range_properties = 
job_node_properties.get("nodeRangeProperties", {})
+            if len(job_node_range_properties) > 1:
+                self.log.warning(
+                    "AWS Batch job (%s) has more than one node group. Only 
returning logs from first group.",
+                    job_id,
+                )
+            if not job_node_range_properties:
+                raise AirflowException(
+                    "AWS Batch job (%s) has no node group. It was described as 
such:\n%s", job_id, job_desc
+                )
+
+            log_configuration = job_node_range_properties[0].get("container", 
{}).get("logConfiguration", {})
+            # "logStreamName" value is not available in the "container" object 
for multinode jobs --
+            # it is available in the "attempts" object
+            job_attempts = job_desc.get("attempts", [])
+            if len(job_attempts):
+                if len(job_attempts) > 1:
+                    self.log.warning(
+                        "AWS Batch job (%s) has had more than one attempt. "
+                        "Only returning logs from the most recent attempt.",
+                        job_id,
+                    )
+                awslogs_stream_name = job_attempts[-1].get("container", 
{}).get("logStreamName")

Review Comment:
   resolving as outdated, code changed in different ways.



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