Skip to content

Commit

Permalink
ecs_service - document circuit breaker feature (#1215)
Browse files Browse the repository at this point in the history
ecs_service - document circuit breaker feature

SUMMARY
Fixes #921
This feature works with the existing code, so this was mainly adding documentation, examples, and an integration test.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ecs_service
ADDITIONAL INFORMATION
The deployment circuit breaker is part of the deployment configuration dictionary, which is already snake<=>camel cased. Thus the existing code was handling 99% of the feature, we just added some type validation, documentation, examples, and an integration test.
- community.aws.ecs_service:
    state: present
    name: test-service
    cluster: test-cluster
    task_definition: test-task-definition
    desired_count: 3
    deployment_configuration:
      deployment_circuit_breaker:
        enable: True
        rollback: True

Reviewed-by: Mark Chappell <None>
  • Loading branch information
karcadia authored Jun 4, 2022
1 parent b351af5 commit a510cbb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- ecs_service - ``deployment_circuit_breaker`` has been added as a supported feature (https://github.com/ansible-collections/community.aws/pull/1215).
51 changes: 50 additions & 1 deletion plugins/modules/ecs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@
minimum_healthy_percent:
type: int
description: A lower limit on the number of tasks in a service that must remain in the RUNNING state during a deployment.
deployment_circuit_breaker:
type: dict
description: The deployment circuit breaker determines whether a service deployment will fail if the service can't reach a steady state.
suboptions:
enable:
type: bool
description: If enabled, a service deployment will transition to a failed state and stop launching new tasks.
rollback:
type: bool
description: If enabled, ECS will roll back your service to the last completed deployment after a failure.
placement_constraints:
description:
- The placement constraints for the tasks in the service.
Expand Down Expand Up @@ -272,6 +282,18 @@
- type: binpack
field: memory
# With deployment circuit breaker (added in version 4.0)
- community.aws.ecs_service:
state: present
name: test-service
cluster: test-cluster
task_definition: test-task-definition
desired_count: 3
deployment_configuration:
deployment_circuit_breaker:
enable: True
rollback: True
# With capacity_provider_strategy (added in version 4.0)
- community.aws.ecs_service:
state: present
Expand Down Expand Up @@ -378,6 +400,19 @@
description: minimumHealthyPercent param
returned: always
type: int
deploymentCircuitBreaker:
description: dictionary of deploymentCircuitBreaker
returned: always
type: complex
contains:
enable:
description: The state of the circuit breaker feature.
returned: always
type: bool
rollback:
description: The state of the rollback feature of the circuit breaker.
returned: always
type: bool
events:
description: list of service events
returned: always
Expand Down Expand Up @@ -494,6 +529,19 @@
description: minimumHealthyPercent param
returned: always
type: int
deploymentCircuitBreaker:
description: dictionary of deploymentCircuitBreaker
returned: always
type: complex
contains:
enable:
description: The state of the circuit breaker feature.
returned: always
type: bool
rollback:
description: The state of the rollback feature of the circuit breaker.
returned: always
type: bool
events:
description: list of service events
returned: always
Expand Down Expand Up @@ -535,7 +583,8 @@

DEPLOYMENT_CONFIGURATION_TYPE_MAP = {
'maximum_percent': 'int',
'minimum_healthy_percent': 'int'
'minimum_healthy_percent': 'int',
'deployment_circuit_breaker': 'dict',
}

from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/targets/ecs_cluster/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ ecs_task_containers:
ecs_service_deployment_configuration:
minimum_healthy_percent: 0
maximum_percent: 100
deployment_circuit_breaker:
enable: true
rollback: true
ecs_service_placement_strategy:
- type: binpack
field: memory
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/targets/ecs_cluster/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@
that:
- ecs_service.changed

- name: check that ECS service was created with deployment_circuit_breaker
assert:
that:
- ecs_service.service.deploymentCircuitBreaker
- ecs_service.service.deploymentCircuitBreaker.enable
- ecs_service.service.deploymentCircuitBreaker.rollback

- name: create same ECS service definition (should not change)
ecs_service:
state: present
Expand Down

0 comments on commit a510cbb

Please sign in to comment.