Skip to content

Commit

Permalink
add task error handling (#36)
Browse files Browse the repository at this point in the history
* add task error handling

* formatting
  • Loading branch information
kylejn27 authored and jacobtomlinson committed Oct 9, 2019
1 parent 1190ff7 commit b0bae69
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions dask_cloudprovider/providers/aws/ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,35 +184,38 @@ 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
[self.task] = (
await self._clients["ecs"].run_task(
cluster=self.cluster_arn,
taskDefinition=self.task_definition_arn,
overrides={
"containerOverrides": [
{
"name": "dask-{}".format(self.task_type),
"environment": dict_to_aws(
self.environment, key_string="name"
),
**self._overrides,
}
]
},
count=1,
launchType="FARGATE" if self.fargate else "EC2",
networkConfiguration={
"awsvpcConfiguration": {
"subnets": self._vpc_subnets,
"securityGroups": self._security_groups,
"assignPublicIp": "ENABLED"
if self._use_public_ip
else "DISABLED",
response = await self._clients["ecs"].run_task(
cluster=self.cluster_arn,
taskDefinition=self.task_definition_arn,
overrides={
"containerOverrides": [
{
"name": "dask-{}".format(self.task_type),
"environment": dict_to_aws(
self.environment, key_string="name"
),
**self._overrides,
}
},
**kwargs
)
)["tasks"]
]
},
count=1,
launchType="FARGATE" if self.fargate else "EC2",
networkConfiguration={
"awsvpcConfiguration": {
"subnets": self._vpc_subnets,
"securityGroups": self._security_groups,
"assignPublicIp": "ENABLED"
if self._use_public_ip
else "DISABLED",
}
},
**kwargs
)

if not response.get("tasks"):
raise RuntimeError(response) # print entire response

[self.task] = response["tasks"]
break
except Exception as e:
timeout.set_exception(e)
Expand Down

0 comments on commit b0bae69

Please sign in to comment.