You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/12/03 15:34:13 UTC

[airflow] branch main updated: Add state details to EMR container failure reason (#19579)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 480c333  Add state details to EMR container failure reason (#19579)
480c333 is described below

commit 480c333c45d31cdfdc63cdfceecd4ad8529eefd4
Author: Junyoung Park <sw...@gmail.com>
AuthorDate: Sat Dec 4 00:33:45 2021 +0900

    Add state details to EMR container failure reason (#19579)
---
 airflow/providers/amazon/aws/hooks/emr_containers.py        | 4 +++-
 tests/providers/amazon/aws/operators/test_emr_containers.py | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/airflow/providers/amazon/aws/hooks/emr_containers.py b/airflow/providers/amazon/aws/hooks/emr_containers.py
index dd65940..b340bea 100644
--- a/airflow/providers/amazon/aws/hooks/emr_containers.py
+++ b/airflow/providers/amazon/aws/hooks/emr_containers.py
@@ -123,7 +123,9 @@ class EMRContainerHook(AwsBaseHook):
                 virtualClusterId=self.virtual_cluster_id,
                 id=job_id,
             )
-            reason = response['jobRun']['failureReason']
+            failure_reason = response['jobRun']['failureReason']
+            state_details = response["jobRun"]["stateDetails"]
+            reason = f"{failure_reason} - {state_details}"
         except KeyError:
             self.log.error('Could not get status of the EMR on EKS job')
         except ClientError as ex:
diff --git a/tests/providers/amazon/aws/operators/test_emr_containers.py b/tests/providers/amazon/aws/operators/test_emr_containers.py
index f7684dc..f04daa0 100644
--- a/tests/providers/amazon/aws/operators/test_emr_containers.py
+++ b/tests/providers/amazon/aws/operators/test_emr_containers.py
@@ -96,11 +96,13 @@ class TestEMRContainerOperator(unittest.TestCase):
     ):
         mock_submit_job.return_value = "jobid_123456"
         mock_check_query_status.return_value = 'FAILED'
-        mock_get_job_failure_reason.return_value = "CLUSTER_UNAVAILABLE"
+        mock_get_job_failure_reason.return_value = (
+            "CLUSTER_UNAVAILABLE - Cluster EKS eks123456 does not exist."
+        )
         with pytest.raises(AirflowException) as ctx:
             self.emr_container.execute(None)
         assert 'EMR Containers job failed' in str(ctx.value)
-        assert 'Error: CLUSTER_UNAVAILABLE' in str(ctx.value)
+        assert 'Error: CLUSTER_UNAVAILABLE - Cluster EKS eks123456 does not exist.' in str(ctx.value)
 
     @mock.patch.object(
         EMRContainerHook,