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

 ##########
 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:
   If you ask for a cluster that doesn't exist it returns `None`
   
https://github.com/apache/airflow/blob/master/airflow/contrib/hooks/emr_hook.py#L52-L59

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to