Skip to content

Commit

Permalink
fix(aws-ecs): correctly sets MinimumHealthyPercentage to 0 (#1661)
Browse files Browse the repository at this point in the history
Zero is a valid value for MinimumHealthyPercentage and therefore should
not be replaced with the default value.

BaseService now explicitly checks if minimumHealthyPercent is null
before setting default value: fixes #1660
  • Loading branch information
Don-CA authored and Elad Ben-Israel committed Feb 6, 2019
1 parent f7c8531 commit ce5966f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/lib/base/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export abstract class BaseService extends cdk.Construct
loadBalancers: new cdk.Token(() => this.loadBalancers),
deploymentConfiguration: {
maximumPercent: props.maximumPercent || 200,
minimumHealthyPercent: props.minimumHealthyPercent || 50
minimumHealthyPercent: props.minimumHealthyPercent === undefined ? 50 : props.minimumHealthyPercent
},
healthCheckGracePeriodSeconds: props.healthCheckGracePeriodSeconds,
/* role: never specified, supplanted by Service Linked Role */
Expand Down
27 changes: 27 additions & 0 deletions packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,33 @@ export = {

test.done();
},

"allows specifying 0 for minimumHealthyPercent"(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef');

taskDefinition.addContainer("web", {
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
});

new ecs.FargateService(stack, "FargateService", {
cluster,
taskDefinition,
minimumHealthyPercent: 0,
});

// THEN
expect(stack).to(haveResourceLike("AWS::ECS::Service", {
DeploymentConfiguration: {
MinimumHealthyPercent: 0,
}
}));

test.done();
},
},

"When setting up a health check": {
Expand Down

0 comments on commit ce5966f

Please sign in to comment.