You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Taragolis (via GitHub)" <gi...@apache.org> on 2023/02/14 19:58:05 UTC

[GitHub] [airflow] Taragolis commented on a diff in pull request #29522: Add support in AWS Batch Operator for multinode jobs

Taragolis commented on code in PR #29522:
URL: https://github.com/apache/airflow/pull/29522#discussion_r1106308351


##########
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.",

Review Comment:
   ```suggestion
                           "AWS Batch job (%s) has had more than one attempt. "
                           "Only returning logs from the most recent attempt.",
   ```



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org