You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2020/08/31 23:50:55 UTC
[airflow] branch master updated: Add placement_strategy option
(#9444)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new f40ac9b Add placement_strategy option (#9444)
f40ac9b is described below
commit f40ac9b151124dbcd87197d6ae38c85191d41f38
Author: Shoichi Kagawa <e4...@gmail.com>
AuthorDate: Tue Sep 1 08:50:08 2020 +0900
Add placement_strategy option (#9444)
---
airflow/providers/amazon/aws/operators/ecs.py | 7 +++++++
tests/providers/amazon/aws/operators/test_ecs.py | 3 +++
2 files changed, 10 insertions(+)
diff --git a/airflow/providers/amazon/aws/operators/ecs.py b/airflow/providers/amazon/aws/operators/ecs.py
index 44b72e5..e2e85d9 100644
--- a/airflow/providers/amazon/aws/operators/ecs.py
+++ b/airflow/providers/amazon/aws/operators/ecs.py
@@ -86,6 +86,9 @@ class ECSOperator(BaseOperator): # pylint: disable=too-many-instance-attributes
:param placement_constraints: an array of placement constraint objects to use for
the task
:type placement_constraints: list
+ :param placement_strategy: an array of placement strategy objects to use for
+ the task
+ :type placement_strategy: list
:param platform_version: the platform version on which your task is running
:type platform_version: str
:param network_configuration: the network configuration for the task
@@ -124,6 +127,7 @@ class ECSOperator(BaseOperator): # pylint: disable=too-many-instance-attributes
launch_type='EC2',
group=None,
placement_constraints=None,
+ placement_strategy=None,
platform_version='LATEST',
network_configuration=None,
tags=None,
@@ -143,6 +147,7 @@ class ECSOperator(BaseOperator): # pylint: disable=too-many-instance-attributes
self.launch_type = launch_type
self.group = group
self.placement_constraints = placement_constraints
+ self.placement_strategy = placement_strategy
self.platform_version = platform_version
self.network_configuration = network_configuration
@@ -180,6 +185,8 @@ class ECSOperator(BaseOperator): # pylint: disable=too-many-instance-attributes
run_opts['group'] = self.group
if self.placement_constraints is not None:
run_opts['placementConstraints'] = self.placement_constraints
+ if self.placement_strategy is not None:
+ run_opts['placementStrategy'] = self.placement_strategy
if self.network_configuration is not None:
run_opts['networkConfiguration'] = self.network_configuration
if self.tags is not None:
diff --git a/tests/providers/amazon/aws/operators/test_ecs.py b/tests/providers/amazon/aws/operators/test_ecs.py
index 16f32b6..73097f1 100644
--- a/tests/providers/amazon/aws/operators/test_ecs.py
+++ b/tests/providers/amazon/aws/operators/test_ecs.py
@@ -67,6 +67,7 @@ class TestECSOperator(unittest.TestCase):
'placement_constraints': [
{'expression': 'attribute:ecs.instance-type =~ t2.*', 'type': 'memberOf'}
],
+ 'placement_strategy': [{'field': 'memory', 'type': 'binpack'}],
'network_configuration': {
'awsvpcConfiguration': {'securityGroups': ['sg-123abc'], 'subnets': ['subnet-123456ab']}
},
@@ -125,6 +126,7 @@ class TestECSOperator(unittest.TestCase):
taskDefinition='t',
group='group',
placementConstraints=[{'expression': 'attribute:ecs.instance-type =~ t2.*', 'type': 'memberOf'}],
+ placementStrategy=[{'field': 'memory', 'type': 'binpack'}],
networkConfiguration={
'awsvpcConfiguration': {'securityGroups': ['sg-123abc'], 'subnets': ['subnet-123456ab']}
},
@@ -156,6 +158,7 @@ class TestECSOperator(unittest.TestCase):
taskDefinition='t',
group='group',
placementConstraints=[{'expression': 'attribute:ecs.instance-type =~ t2.*', 'type': 'memberOf'}],
+ placementStrategy=[{'field': 'memory', 'type': 'binpack'}],
networkConfiguration={
'awsvpcConfiguration': {'securityGroups': ['sg-123abc'], 'subnets': ['subnet-123456ab'],}
},