Skip to content

Commit

Permalink
Merge pull request #92 from joeschmid/allow-platform-version
Browse files Browse the repository at this point in the history
Support specifying platformVersion for Fargate
  • Loading branch information
martindurant committed Apr 29, 2020
2 parents 915596e + f78b601 commit ce6e003
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions dask_cloudprovider/cloudprovider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ cloudprovider:
execution_role_arn: "" # Arn of existing execution role to use (if not set one will be created)
task_role_arn: "" # Arn of existing task role to use (if not set one will be created)
task_role_policies: [] # List of policy arns to attach to tasks (e.g S3 read only access)
# platform_version: "LATEST" # Fargate platformVersion string like "1.4.0" or "LATEST"

cloudwatch_logs_group: "" # Name of existing cloudwatch logs group to use (if not set one will be created)
cloudwatch_logs_stream_prefix: "{cluster_name}" # Stream prefix template
Expand Down
19 changes: 19 additions & 0 deletions dask_cloudprovider/providers/aws/ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class Task:
name: str (optional)
Name for the task. Currently used for the --namecommand line argument to dask-worker.
platform_version: str (optional)
Version of the AWS Fargate platform to use, e.g. "1.4.0" or "LATEST". This
setting has no effect for the EC2 launch type.
fargate_use_private_ip: bool (optional)
Whether to use a private IP (if True) or public IP (if False) with Fargate.
Defaults to False, i.e. public IP.
Expand Down Expand Up @@ -104,6 +108,7 @@ def __init__(
tags,
find_address_timeout,
name=None,
platform_version=None,
fargate_use_private_ip=False,
**kwargs
):
Expand All @@ -129,6 +134,7 @@ def __init__(
self.environment = environment or {}
self.tags = tags
self._find_address_timeout = find_address_timeout
self.platform_version = platform_version
self._fargate_use_private_ip = fargate_use_private_ip
self.kwargs = kwargs
self.status = "created"
Expand Down Expand Up @@ -202,6 +208,8 @@ async def start(self):
if await self._is_long_arn_format_enabled()
else {}
) # Tags are only supported if you opt into long arn format so we need to check for that
if self.platform_version and self.fargate:
kwargs["platformVersion"] = self.platform_version
async with self._client("ecs") as ecs:
response = await ecs.run_task(
cluster=self.cluster_arn,
Expand Down Expand Up @@ -546,6 +554,11 @@ class ECSCluster(SpecCluster):
and this operation takes a while.
Default ``False``.
platform_version: str (optional)
Version of the AWS Fargate platform to use, e.g. "1.4.0" or "LATEST". This
setting has no effect for the EC2 launch type.
Defaults to ``None``
fargate_use_private_ip: bool (optional)
Whether to use a private IP (if True) or public IP (if False) with Fargate.
Expand Down Expand Up @@ -590,6 +603,7 @@ def __init__(
aws_access_key_id=None,
aws_secret_access_key=None,
region_name=None,
platform_version=None,
fargate_use_private_ip=False,
**kwargs
):
Expand Down Expand Up @@ -625,6 +639,7 @@ def __init__(
self._aws_access_key_id = aws_access_key_id
self._aws_secret_access_key = aws_secret_access_key
self._region_name = region_name
self._platform_version = platform_version
self._lock = asyncio.Lock()
self.session = aiobotocore.get_session()
super().__init__(**kwargs)
Expand Down Expand Up @@ -711,6 +726,9 @@ async def _start(self,):
if self._cluster_name_template is None:
self._cluster_name_template = self.config.get("cluster_name_template")

if self._platform_version is None:
self._platform_version = self.config.get("platform_version")

if self.cluster_arn is None:
self.cluster_arn = (
self.config.get("cluster_arn") or await self._create_cluster()
Expand Down Expand Up @@ -787,6 +805,7 @@ async def _start(self,):
"environment": self._environment,
"tags": self.tags,
"find_address_timeout": self._find_address_timeout,
"platform_version": self._platform_version,
"fargate_use_private_ip": self._fargate_use_private_ip,
}
scheduler_options = {
Expand Down

0 comments on commit ce6e003

Please sign in to comment.