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

fix(ecs-patterns): handle desired task count being set to 0 #4722

Merged
merged 14 commits into from
Nov 4, 2019

Conversation

nmussy
Copy link
Contributor

@nmussy nmussy commented Oct 28, 2019

Allow desired task count to be set to 0 for the following (defaults to 1 when the property is undefined):

  • QueueProcessingServiceBase.desiredTaskCount property, affects:
    • QueueProcessingEc2Service
    • QueueProcessingFargateService
      Note: If desired task count is set to 0, maxScalingCapacity must be defined with a value greater than 0.

Throw exception when desired task count is set to 0 for the following (defaults to 1 when the property is undefined):

  • ApplicationLoadBalancedServiceBase.desiredCount property, affects:
    • ApplicationLoadBalancedEc2Service
    • ApplicationLoadBalancedFargateService
  • NetworkLoadBalancedServiceBase.desiredCount property, affects:
    • NetworkLoadBalancedEc2Service
    • NetworkLoadBalancedFargateService
  • ScheduledTaskBase.desiredTaskCount property, affects:
    • ScheduledEc2Task
    • ScheduledFargateTask

Fixes #4719


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@nmussy nmussy requested a review from SoManyHs as a code owner October 28, 2019 14:46
@mergify
Copy link
Contributor

mergify bot commented Oct 28, 2019

Thanks so much for taking the time to contribute to the AWS CDK ❤️

We will shortly assign someone to review this pull request and help get it
merged. In the meantime, please take a minute to make sure you follow this
checklist
:

  • PR title type(scope): text
    • type: fix, feat, refactor go into CHANGELOG, chore is hidden
    • scope: name of module without aws- or cdk- prefix or postfix (e.g. s3 instead of aws-s3-deployment)
    • text: use all lower-case, do not end with a period, do not include issue refs
  • PR Description
    • Rationale: describe rationale of change and approach taken
    • Issues: indicate issues fixed via: fixes #xxx or closes #xxx
    • Breaking?: last paragraph: BREAKING CHANGE: <describe what changed + link for details>
  • Testing
    • Unit test added. Prefer to add a new test rather than modify existing tests
    • CLI or init templates change? Re-run/add CLI integration tests
  • Documentation
    • README: update module README to describe new features
    • API docs: public APIs must be documented. Copy from official AWS docs when possible
    • Design: for significant features, follow design process

@SomayaB SomayaB added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Oct 28, 2019
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@piradeepk piradeepk changed the title fix(ecs-patterns): allow 0 desired task count fix(ecs-patterns): allow queueprocessingservice to accept a desired task count of 0 Oct 28, 2019
@nmussy
Copy link
Contributor Author

nmussy commented Oct 28, 2019

@pkandasamy91 Your title is incorrect, this PR doesn't only cover queueprocessingservice, but also ApplicationLoadBalanced and NetworkLoadBalanced services

Copy link
Contributor

@piradeepk piradeepk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to make this change. I don't think this follows the best practices for all patterns, and have added a couple comments

@nmussy
Copy link
Contributor Author

nmussy commented Oct 29, 2019

@pkandasamy91 We don't have to allow 0, seeing the anti-patterns you described in the issue.

This problem now is that is user isn't aware that they are not able to set a capacity to 0, and the CDK will silently bump it to 1. The way I see it, we can go about it two ways:

  • Allow 0, warn the user
  • Document the minimum value, throw if set to 0

What do you think?

@piradeepk
Copy link
Contributor

piradeepk commented Oct 29, 2019

@pkandasamy91 We don't have to allow 0, seeing the anti-patterns you described in the issue.

This problem now is that is user isn't aware that they are not able to set a capacity to 0, and the CDK will silently bump it to 1. The way I see it, we can go about it two ways:

* Allow 0, warn the user

* Document the minimum value, throw if set to 0

What do you think?

I definitely agree we need a way to notify users. I like the idea of adding to the documentation and throwing an exception. With a warning, it could easily be missed.

@mergify mergify bot dismissed piradeepk’s stale review October 29, 2019 15:31

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@nmussy
Copy link
Contributor Author

nmussy commented Oct 30, 2019

@pkandasamy91 I also missed ScheduledTaskBase:

https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-ecs-patterns/lib/base/scheduled-task-base.ts#L108

Should we allow it like SQS, or throw like ALB/NLB?

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@piradeepk piradeepk changed the title fix(ecs-patterns): allow queueprocessingservice to accept a desired task count of 0 fix(ecs-patterns): allow or throw an exception when desired task count is set to 0 Oct 30, 2019
@piradeepk
Copy link
Contributor

@pkandasamy91 I also missed ScheduledTaskBase:

https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-ecs-patterns/lib/base/scheduled-task-base.ts#L108

Should we allow it like SQS, or throw like ALB/NLB?

I can't see a use case where a user would schedule a task to kick off with 0 desiredCount. For the time being I'm leaning towards throwing an exception. If a use case arises it can be changed after the fact as it wouldn't be a breaking change.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@piradeepk
Copy link
Contributor

Please also add a note in your description for what the expected behaviour of each construct is (which ones throw vs which ones allow)

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@piradeepk piradeepk added the pr/do-not-merge This PR should not be merged at this time. label Oct 31, 2019
@piradeepk piradeepk changed the title fix(ecs-patterns): allow or throw an exception when desired task count is set to 0 fix(ecs-patterns): handle desired task count being set to 0 Oct 31, 2019
@piradeepk piradeepk removed the pr/do-not-merge This PR should not be merged at this time. label Oct 31, 2019
@piradeepk piradeepk removed the request for review from RomainMuller October 31, 2019 16:52
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot dismissed piradeepk’s stale review November 4, 2019 09:00

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@piradeepk piradeepk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to resolve this issue, and for addressing all of the feedback!

@piradeepk piradeepk added the @aws-cdk/aws-ecs-patterns Related to ecs-patterns library label Nov 4, 2019
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Nov 4, 2019

Thank you for contributing! Your pull request is now being automatically merged.

@mergify mergify bot merged commit c31ca27 into aws:master Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container @aws-cdk/aws-ecs-patterns Related to ecs-patterns library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QueueProcessingFargateService unable to set desiredCount to zero
5 participants