CircleCI-Public / aws-ecs-orb

An orb that simplifies deployment to Amazon's Elastic Container Service (ECS). Supports both EC2 and Fargate launch types.
https://circleci.com/orbs/registry/orb/circleci/aws-ecs
MIT License
51 stars 80 forks source link

Any way to handle DeploymentLimitExceededException? #181

Closed agustints closed 2 years ago

agustints commented 2 years ago

What happened:

When running two workflows simultaneously, it fails because there is already one running, is there any way to avoid this and have it wait to do the second deployment?

An error occurred (DeploymentLimitExceededException) when calling the CreateDeployment operation: The Deployment Group 'x' already has an active Deployment 'd-id-x' Exited with code exit status 254 CircleCI received exit code 254

brivu commented 2 years ago

Hey @agustints,

Can you send me your config so I can check it out? Generally speaking, we use the requires parameter for this use case. Check out this snippet below:

  test_and_deploy:
    jobs:
      - sam/deploy:
          name: deploy-staging
          stack-name: staging-stack
          template: ./path/to/template.yml
      - test_my_api:
          requires:
            - deploy-staging
      - sam/deploy:
          name: deploy-production
          requires:
            - test_my_api
          stack-name: production-stack
          template: ./path/to/template.yml

As you can see, sam/deploy is ran twice. However, because the second run has a requires parameter with test_my_api as its value, it will not run until the test_my_api job is complete. That's how we recommend doing this but I'm not completely sure this will work in your use case unless I can see the snippet of your config file.

Let me know if requires works for you.

Best, Brian

brivu commented 2 years ago

Hey @agustints,

I'm going to go ahead a close this issue for now. If you still have trouble, please feel free to open it again!

Best , Brian

agustints commented 2 years ago

Hello, I will share with you an example tomorrow

agustints commented 2 years ago

The problem occurs when 2 merges are done at the same time and the same routine is executed 2 times at the same time, there the exception occurs.
At that point the first deployment will work and the second will fail because one is in progress. The idea would be to wait for the first one to finish and run the update service when there is no deployment in progress.

brivu commented 2 years ago

Hey @agustints,

Just wanted to check in and see if you're able to figure this out. if you send me your config, I'd be happy to take a look.

Brian