Skip to content

Commit b1fc916

Browse files
eacherkan-aternitypatchback[bot]
authored andcommitted
ecs_taskdefinition: use aws_retry to avoid throttling exception (#2124)
SUMMARY Fixes #2123 by adding aws_retry=True to the API calls. ISSUE TYPE Bugfix Pull Request COMPONENT NAME ecs_taskdefinition ADDITIONAL INFORMATION We observed that ecs_taskdefinition intermittently causes a ThrottlingException when running on a task definition with a large number of revisions. Looking at the code, it appears that describe_task_definitions loops over the revisions without using the retry mechanism. This PR attempts to solve the problem by adding aws_retry=True to the API calls. Due to the nature of the problem (intermittent throttling by AWS), I couldn't devise automated tests that validate the fix. Reviewed-by: Alina Buzachis Reviewed-by: Mark Chappell Reviewed-by: Eli Acherkan (cherry picked from commit 97131ec)
1 parent 142fb96 commit b1fc916

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- ecs_taskdefinition - avoid throttling exceptions on task definitions with a large number of revisions by using the retry mechanism (https://github.com/ansible-collections/community.aws/issues/2123).

plugins/modules/ecs_taskdefinition.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ def fetch():
916916
if data["nextToken"]:
917917
params["nextToken"] = data["nextToken"]
918918

919-
result = self.ecs.list_task_definitions(**params)
919+
result = self.ecs.list_task_definitions(aws_retry=True, **params)
920920
data["taskDefinitionArns"] += result["taskDefinitionArns"]
921921
data["nextToken"] = result.get("nextToken", None)
922922
return data["nextToken"] is not None
@@ -929,15 +929,15 @@ def fetch():
929929
return list(
930930
sorted(
931931
[
932-
self.ecs.describe_task_definition(taskDefinition=arn)["taskDefinition"]
932+
self.ecs.describe_task_definition(aws_retry=True, taskDefinition=arn)["taskDefinition"]
933933
for arn in data["taskDefinitionArns"]
934934
],
935935
key=lambda td: td["revision"],
936936
)
937937
)
938938

939939
def deregister_task(self, taskArn):
940-
response = self.ecs.deregister_task_definition(taskDefinition=taskArn)
940+
response = self.ecs.deregister_task_definition(aws_retry=True, taskDefinition=taskArn)
941941
return response["taskDefinition"]
942942

943943

0 commit comments

Comments
 (0)