airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AIRFLOW-3297) EmrStepSensor marks cancelled step as successful
Date Wed, 07 Nov 2018 15:09:00 GMT

    [ https://issues.apache.org/jira/browse/AIRFLOW-3297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16678358#comment-16678358
] 

ASF GitHub Bot commented on AIRFLOW-3297:
-----------------------------------------

ashb closed pull request #4152: AIRFLOW-3297 added possible states to the EMR step sensor
URL: https://github.com/apache/incubator-airflow/pull/4152
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/contrib/sensors/emr_step_sensor.py b/airflow/contrib/sensors/emr_step_sensor.py
index 65bb7c95b1..315fdf7427 100644
--- a/airflow/contrib/sensors/emr_step_sensor.py
+++ b/airflow/contrib/sensors/emr_step_sensor.py
@@ -32,8 +32,8 @@ class EmrStepSensor(EmrBaseSensor):
     :type step_id: str
     """
 
-    NON_TERMINAL_STATES = ['PENDING', 'RUNNING', 'CONTINUE']
-    FAILED_STATE = ['CANCELLED', 'FAILED']
+    NON_TERMINAL_STATES = ['PENDING', 'RUNNING', 'CONTINUE', 'CANCEL_PENDING']
+    FAILED_STATE = ['CANCELLED', 'FAILED', 'INTERRUPTED']
     template_fields = ['job_flow_id', 'step_id']
     template_ext = ()
 
diff --git a/tests/contrib/sensors/test_emr_step_sensor.py b/tests/contrib/sensors/test_emr_step_sensor.py
index 2a105a9393..08cb8d1aea 100644
--- a/tests/contrib/sensors/test_emr_step_sensor.py
+++ b/tests/contrib/sensors/test_emr_step_sensor.py
@@ -83,6 +83,35 @@
     }
 }
 
+DESCRIBE_JOB_STEP_INTERRUPTED_RETURN = {
+    'ResponseMetadata': {
+        'HTTPStatusCode': 200,
+        'RequestId': '8dee8db2-3719-11e6-9e20-35b2f861a2a6'
+    },
+    'Step': {
+        'ActionOnFailure': 'CONTINUE',
+        'Config': {
+            'Args': [
+                '/usr/lib/spark/bin/run-example',
+                'SparkPi',
+                '10'
+            ],
+            'Jar': 'command-runner.jar',
+            'Properties': {}
+        },
+        'Id': 's-VK57YR1Z9Z5N',
+        'Name': 'calculate_pi',
+        'Status': {
+            'State': 'INTERRUPTED',
+            'StateChangeReason': {},
+            'Timeline': {
+                'CreationDateTime': datetime(2016, 6, 20, 19, 0, 18, tzinfo=tzlocal()),
+                'StartDateTime': datetime(2016, 6, 20, 19, 2, 34, tzinfo=tzlocal())
+            }
+        }
+    }
+}
+
 DESCRIBE_JOB_STEP_COMPLETED_RETURN = {
     'ResponseMetadata': {
         'HTTPStatusCode': 200,
@@ -158,6 +187,17 @@ def test_step_cancelled(self):
         with patch('boto3.session.Session', self.boto3_session_mock):
             self.assertRaises(AirflowException, self.sensor.execute, None)
 
+    def test_step_interrupted(self):
+        self.emr_client_mock.describe_step.side_effect = [
+            DESCRIBE_JOB_STEP_RUNNING_RETURN,
+            DESCRIBE_JOB_STEP_INTERRUPTED_RETURN
+        ]
+
+        self.boto3_client_mock = MagicMock(return_value=self.emr_client_mock)
+
+        with patch('boto3.session.Session', self.boto3_session_mock):
+            self.assertRaises(AirflowException, self.sensor.execute, None)
+
 
 if __name__ == '__main__':
     unittest.main()


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


> EmrStepSensor marks cancelled step as successful 
> -------------------------------------------------
>
>                 Key: AIRFLOW-3297
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-3297
>             Project: Apache Airflow
>          Issue Type: Bug
>            Reporter: Dana Assa
>            Assignee: Dana Assa
>            Priority: Minor
>             Fix For: 2.0.0, 1.10.1
>
>
> When a step is manually cancelled or when the cluster is terminated unexpectedly, an
EMR step can reach 'CANCEL_PENDING' state or 'INTERRUPTED' state.
> These states are not mentioned as FAILED_STATES nor as NON_TERMINAL_STATES in the "EmrStepSensor"
class, thus the sensor returns True and the Airflow stage is marked as success instead of
failed.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message