airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kaxiln...@apache.org
Subject incubator-airflow git commit: [AIRFLOW-2435] Add launch_type to ECSOperator to allow FARGATE
Date Mon, 14 May 2018 18:51:21 GMT
Repository: incubator-airflow
Updated Branches:
  refs/heads/v1-10-test b0a09abed -> ea3e1a47a


[AIRFLOW-2435] Add launch_type to ECSOperator to allow FARGATE

Closes #3329 from ThomasVdBerge/ecs-fargate

(cherry picked from commit 776669ab60d92f56d1f1804b003ad4372c13cbfa)
Signed-off-by: Kaxil Naik <kaxilnaik@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/ea3e1a47
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/ea3e1a47
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/ea3e1a47

Branch: refs/heads/v1-10-test
Commit: ea3e1a47a9655bd77abf8e32cf8503ca2a97e590
Parents: b0a09ab
Author: Thomas Van den Berge <info@thomasvdberge.be>
Authored: Mon May 14 19:50:05 2018 +0100
Committer: Kaxil Naik <kaxilnaik@gmail.com>
Committed: Mon May 14 19:51:07 2018 +0100

----------------------------------------------------------------------
 airflow/contrib/operators/ecs_operator.py    | 8 ++++++--
 tests/contrib/operators/test_ecs_operator.py | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/ea3e1a47/airflow/contrib/operators/ecs_operator.py
----------------------------------------------------------------------
diff --git a/airflow/contrib/operators/ecs_operator.py b/airflow/contrib/operators/ecs_operator.py
index 5650cce..104898c 100644
--- a/airflow/contrib/operators/ecs_operator.py
+++ b/airflow/contrib/operators/ecs_operator.py
@@ -40,6 +40,8 @@ class ECSOperator(BaseOperator):
             credential boto3 strategy will be used (http://boto3.readthedocs.io/en/latest/guide/configuration.html).
     :type aws_conn_id: str
     :param region_name: region name to use in AWS Hook. Override the region_name in connection
(if provided)
+    :param launch_type: the launch type on which to run your task ('EC2' or 'FARGATE')
+    :type: launch_type: str
     """
 
     ui_color = '#f0ede4'
@@ -49,7 +51,7 @@ class ECSOperator(BaseOperator):
 
     @apply_defaults
     def __init__(self, task_definition, cluster, overrides,
-                 aws_conn_id=None, region_name=None, **kwargs):
+                 aws_conn_id=None, region_name=None, launch_type='EC2', **kwargs):
         super(ECSOperator, self).__init__(**kwargs)
 
         self.aws_conn_id = aws_conn_id
@@ -57,6 +59,7 @@ class ECSOperator(BaseOperator):
         self.task_definition = task_definition
         self.cluster = cluster
         self.overrides = overrides
+        self.launch_type = launch_type
 
         self.hook = self.get_hook()
 
@@ -76,7 +79,8 @@ class ECSOperator(BaseOperator):
             cluster=self.cluster,
             taskDefinition=self.task_definition,
             overrides=self.overrides,
-            startedBy=self.owner
+            startedBy=self.owner,
+            launchType=self.launch_type
         )
 
         failures = response['failures']

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/ea3e1a47/tests/contrib/operators/test_ecs_operator.py
----------------------------------------------------------------------
diff --git a/tests/contrib/operators/test_ecs_operator.py b/tests/contrib/operators/test_ecs_operator.py
index 3b38973..b5d3141 100644
--- a/tests/contrib/operators/test_ecs_operator.py
+++ b/tests/contrib/operators/test_ecs_operator.py
@@ -97,6 +97,7 @@ class TestECSOperator(unittest.TestCase):
         self.aws_hook_mock.return_value.get_client_type.assert_called_once_with('ecs', region_name='eu-west-1')
         client_mock.run_task.assert_called_once_with(
             cluster='c',
+            launchType='EC2',
             overrides={},
             startedBy=mock.ANY,  # Can by 'airflow' or 'Airflow'
             taskDefinition='t'
@@ -119,6 +120,7 @@ class TestECSOperator(unittest.TestCase):
         self.aws_hook_mock.return_value.get_client_type.assert_called_once_with('ecs', region_name='eu-west-1')
         client_mock.run_task.assert_called_once_with(
             cluster='c',
+            launchType='EC2',
             overrides={},
             startedBy=mock.ANY,  # Can by 'airflow' or 'Airflow'
             taskDefinition='t'


Mime
View raw message