You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/12/31 15:52:30 UTC

[GitHub] [airflow] nuclearpinguin commented on a change in pull request #6898: [AIRFLOW-6432] Raise appropriate exception in EmrAddStepsOperator when using job_flow_name and no cluster is found by that name

nuclearpinguin commented on a change in pull request #6898: [AIRFLOW-6432] Raise appropriate exception in EmrAddStepsOperator when using job_flow_name and no cluster is found by that name
URL: https://github.com/apache/airflow/pull/6898#discussion_r362238354
 
 

 ##########
 File path: airflow/contrib/operators/emr_add_steps_operator.py
 ##########
 @@ -68,12 +68,14 @@ def __init__(
         self.steps = steps
 
     def execute(self, context):
-        emr = EmrHook(aws_conn_id=self.aws_conn_id).get_conn()
+        emr_hook = EmrHook(aws_conn_id=self.aws_conn_id)
 
-        job_flow_id = self.job_flow_id
+        emr = emr_hook.get_conn()
 
+        job_flow_id = self.job_flow_id or emr_hook.get_cluster_id_by_name(self.job_flow_name,
+                                                                          self.cluster_states)
         if not job_flow_id:
-            job_flow_id = emr.get_cluster_id_by_name(self.job_flow_name, self.cluster_states)
+            raise AirflowException(f'No cluster found for name: {self.job_flow_name}')
 
 Review comment:
   No I start to think when this exception will be reached? When `emr_hook.get_cluster_id_by_name` return `None`. Is it possible or this will fail when calling `emr_hook.get_cluster_id_by_name` whith `self.job_flow_name=None`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services