Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation to ensure ecs service is deployed successfully #91

Closed

Conversation

raags
Copy link

@raags raags commented Jun 7, 2020

SUMMARY

This expands the existing delay and repeat parameters to also check if a service is deployed successfully. This is done by checking the running count is equal to the desired count for the active deployment.

When the delay is set to 0, it'll disable this check.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

ecs_service

ADDITIONAL INFORMATION

Currently, the ecs_service module starts a ECS service deployment but doesn't validate the deployment success. This change will optionally validate if the deployment succeeded, giving early feedback on the service status.

This expands the existing delay and repeat parameters to also
check if a service is deployed successfully. This is done by checking
the running count is equal to the desired count for the active
deployment.

When delay is set to 0, it'll disable this check.
@raags raags force-pushed the rags/add-ecs-service-validation branch from d9818a7 to 16e84d8 Compare June 7, 2020 13:18
@jillr jillr changed the base branch from master to main July 2, 2020 19:48
@ansibullbot
Copy link

@ansibullbot ansibullbot added affects_2.10 community_review feature This issue/PR relates to a feature request module module needs_triage new_contributor Help guide this first time contributor stale_ci CI is older than 7 days, rerun before merging labels Aug 19, 2020
@ansibullbot ansibullbot added the plugins plugin (any type) label Aug 28, 2020
@jillr jillr added the pr_day Has been reviewed during a PR review Day. https://github.com/ansible/community/issues/407 label Dec 1, 2020
@markuman
Copy link
Member

markuman commented Dec 1, 2020

@raags thanks for your pr.

basically waiting for desired_count becomes equal running_count might not be sufficient in case your ecs service has got a load balancer configuration.
in this case you must wait until desired_count becomes equal to healthy targets in the belonging target group.
In case you update just the taskdefinition and the desired_count has not changed, it becomes more complicated. Because you must only count the healthy targets with the new taskdefinition.

In case you doesn't have a load balancer configuration (you do some background processing jobs with ecs), it might be sufficient.

You can achive something similar by using the elb_target_group_info modules.

- name: wait until at least one target is registered and healthy
  elb_target_group_facts:
    names:
      - "{{ SERVICE }}"
    collect_targets_health: yes
  register: TG
  retries: 10
  delay: 15
  until: TG.target_groups[0].targets_health_description | count == DESIRED_COUNT and TG.target_groups[0].targets_health_description[0].target_health.state == "healthy"

But as you see, it gets complicated. But it is definitely a "very nice to have" feature.

Furthermore, consider to add a waiter to the waiters.py file in the amazon.aws collection rather than writing a loop inside your module.
You'll find an example in this blog post by @jillr https://www.ansible.com/blog/getting-started-with-aws-ansible-module-development

@tremble
Copy link
Contributor

tremble commented Oct 22, 2021

There's actually 2 waiters already:

They test for the states you're interested in. We often add waiters to amazon.aws because the built in waiters bomb out if you hit the API rate limits

@markuman markuman mentioned this pull request May 26, 2022
10 tasks
@tremble tremble removed the pr_day Has been reviewed during a PR review Day. https://github.com/ansible/community/issues/407 label Jul 5, 2022
@tremble
Copy link
Contributor

tremble commented Jul 7, 2022

Looking a little deeper into this PR, it looks like it's been superseded by #1209 which uses the botocore waiters.

@raags Thanks for taking the time to submit this PR. It looks like this PR stalled out a couple of years ago, and looking at the module as it stands today I believe that this has been achieved through a different mechanism. The updated behaviour should be available with community.aws 4.1.0. There's no fixed release dates yet.

I'm going to close out this PR, hopefully any future PRs won't spend quite so long waiting on reviews (we're finally getting on top of our backlog)

@tremble tremble closed this Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.10 community_review feature This issue/PR relates to a feature request has_issue module module new_contributor Help guide this first time contributor plugins plugin (any type) stale_ci CI is older than 7 days, rerun before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants