You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2018/05/14 18:50:32 UTC

incubator-airflow git commit: [AIRFLOW-2435] Add launch_type to ECSOperator to allow FARGATE

Repository: incubator-airflow
Updated Branches:
  refs/heads/master 06e180636 -> 776669ab6


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

Closes #3329 from ThomasVdBerge/ecs-fargate


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

Branch: refs/heads/master
Commit: 776669ab60d92f56d1f1804b003ad4372c13cbfa
Parents: 06e1806
Author: Thomas Van den Berge <in...@thomasvdberge.be>
Authored: Mon May 14 19:50:05 2018 +0100
Committer: Kaxil Naik <ka...@gmail.com>
Committed: Mon May 14 19:50:05 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/776669ab/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/776669ab/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'