Skip to content

Commit

Permalink
fix ecs_cluster integration test (#1145) (#1153)
Browse files Browse the repository at this point in the history
[PR #1145/35f4f592 backport][stable-2] fix ecs_cluster integration test

This is a backport of PR #1145 as merged into main (35f4f59).
SUMMARY

ecs_cluster: make ecs_cluster integration test work again - as it is

bugs I've hit and must be fixed to complete this challenge

ecs_taskdefinition: fix change detection of changing launch_type parameter
ecs_service:

compare of task_definition never works and results always in a changed task
change detect of health_check_grace_period_seconds was never implemented, but tested and failing, after the task_definition is compared correctly







ref: #1142
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
ecs_taskdefinition
ecs_service
ADDITIONAL INFORMATION
basically the existing test tasks are not changed. just sorted and removed what was marked as fixme because it's simple not possible (changing network settings of a created service).

Reviewed-by: Markus Bergholz <[email protected]>
  • Loading branch information
patchback[bot] authored May 25, 2022
1 parent 702fe73 commit c36f8db
Show file tree
Hide file tree
Showing 7 changed files with 1,041 additions and 2,017 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/0000-ecs_taskdefinition_fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bugfixes:
- ecs_taskdefinition - fix broken change detect of ``launch_type`` parameter (https://github.com/ansible-collections/community.aws/pull/1145).
- ecs_service - fix broken compare of ``task_definition`` that results always in a changed task (https://github.com/ansible-collections/community.aws/pull/1145).
- ecs_service - add missing change detect of ``health_check_grace_period_seconds`` parameter (https://github.com/ansible-collections/community.aws/pull/1145).
9 changes: 8 additions & 1 deletion plugins/modules/ecs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,14 @@ def describe_service(self, cluster_name, service_name):
raise Exception("Unknown problem describing service %s." % service_name)

def is_matching_service(self, expected, existing):
if expected['task_definition'] != existing['taskDefinition']:
# aws returns the arn of the task definition
# arn:aws:ecs:eu-central-1:123456789:task-definition/ansible-fargate-nginx:3
# but the user is just entering
# ansible-fargate-nginx:3
if expected['task_definition'] != existing['taskDefinition'].split('/')[-1]:
return False

if expected.get('health_check_grace_period_seconds') != existing.get('healthCheckGracePeriodSeconds'):
return False

if (expected['load_balancers'] or []) != existing['loadBalancers']:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ecs_taskdefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ def _task_definition_matches(requested_volumes, requested_containers, requested_
if requested_task_role_arn != td.get('taskRoleArn', ""):
return None

if requested_launch_type is not None and requested_launch_type not in td.get('compatibilities', []):
if requested_launch_type is not None and requested_launch_type not in td.get('requiresCompatibilities', []):
return None

existing_volumes = td.get('volumes', []) or []
Expand Down
Loading

0 comments on commit c36f8db

Please sign in to comment.