aws-samples / aws-samples/aws-codedeploy-samples

Failed deployments using ASGs and elb scripts reduce ASG capacity

Open
#70 6 comments 3 reactions 0 assignees View on GitHub
bug enhancement
Dominant language
Shell
Stars
639
Forks
778
PR merge metrics
No merged PRs in 30d

Description

During the deregister scripts, if the host is a part of an ASG and min size matches desired size, the [ASG min size setting gets decremented](https://github.com/awslabs/aws-codedeploy-samples/blob/master/load-balancing/elb/common_functions.sh#L299) so that ASG does not spin up a new instance, and when the host goes back into service, the [ASG min size gets incremented](https://github.com/awslabs/aws-codedeploy-samples/blob/master/load-balancing/elb/common_functions.sh#L394). However, if the deployment fails, the script will never increase the capacity, leaving the ASG with one less min size. Since putting a host into standby reduces the desired capacity, an ASG could have its min size reduced by multiple hosts during a deployment, and it will never be increased back to where it was.

When the min size gets decremented, a [flag gets set in a temporary file](https://github.com/awslabs/aws-codedeploy-samples/blob/master/load-balancing/elb/common_functions.sh#L311) that's around for the life of the deployment, but will not be viewed by any subsequent deployments. One option might be to set the flag in a permanent location to track the state mutations.

Issue #57 is an example of this.

### Supported Solution

If CodeDeploy customers are not aware, [CodeDeploy has direct support for some ELB situations](http://docs.aws.amazon.com/codedeploy/latest/userguide/integrations-aws-elastic-load-balancing.html). As of 5/1/17, [CodeDeploy started supporting classic ELB](https://aws.amazon.com/about-aws/whats-new/2017/05/aws-codedeploy-now-integrates-with-elastic-load-balancing/) via the service, which handles all of the registering and deregistering from the load balancer and allows additional lifecycle events, and it solves many of the limitations in these scripts. If your use case is not currently supported (i.e. you use application ELB), check in occasionally [here](http://docs.aws.amazon.com/codedeploy/latest/userguide/integrations-aws-elastic-load-balancing.html) to see if CodeDeploy has added support.

If you onboard with CodeDeploy ELB support, you should no longer need to use these load balancer scripts.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.