[
https://issues.apache.org/jira/browse/AIRFLOW-5328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16920802#comment-16920802
]
Ash Berlin-Taylor commented on AIRFLOW-5328:
--------------------------------------------
This example dag/custom sensor would do what you want:
{code:python}
from airflow import DAG
from airflow.contrib.sensors.emr_job_flow_sensor import EmrJobFlowSensor
from airflow.contrib.emr_create_job_flow_operator import
EmrCreateJobFlowOperator
class EmrClusterReadySensor(EmrJobFlowSensor):
NON_TERMINAL_STATES = ['STARTING', 'BOOTSTRAPPING', 'TERMINATING']
dag = DAG(....)
with dag:
EmrCreateJobFlowOperator(task_id='create_cluster')
EmrClusterReadySensor(
task_id='wait_cluster_ready',
job_flow_id='{{ ti.xcom_pull(task_ids="create_cluter") }}',
)
{code}
Adding a new flag to EmrJobFlowSensor so that you could do something like:
{code:python}
EmrJobFlowSensor(
task_id='wait_cluster_ready',
job_flow_id='{{ ti.xcom_pull(task_ids="create_cluter") }}',
wait_until_bootstrapped=True,
)
{code}
might be a nice way to add this to the existing sensor.
> EmrCreateJobFlowOperator success when EMR isn't ready
> -----------------------------------------------------
>
> Key: AIRFLOW-5328
> URL: https://issues.apache.org/jira/browse/AIRFLOW-5328
> Project: Apache Airflow
> Issue Type: Bug
> Components: aws, operators
> Affects Versions: 1.10.4
> Reporter: Elad
> Priority: Major
>
> EmrCreateJobFlowOperator returns almost instantly.
> It shouldn't return until the Emr cluster id ready.
> It doesn't make sense to submit tasks to EMR when the cluster isn't ready.
> Currently, tasks are submitted and waiting until the cluster will finish its
> initialization.
> This can be checked with Waiter:
> [https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/emr.html]
> something like:
> {code:java}
> waiter =
> client.get_waiter('cluster_running').wait(ClusterId=response['JobFlowId'],
> WaiterConfig={'Delay': 32, 'MaxAttempts': 60}){code}
--
This message was sent by Atlassian Jira
(v8.3.2#803003)