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(autoscaling): update validation on maxInstanceLifetime #19584

Merged
merged 2 commits into from
Apr 8, 2022
Merged

fix(autoscaling): update validation on maxInstanceLifetime #19584

merged 2 commits into from
Apr 8, 2022

Conversation

jungseoklee
Copy link
Contributor

Summary

This patch fixes the following bugs in maxInstanceLifetime validation by aligning with CFN doc:

  • A lower bound of maxInstanceLifetime is 1 day, not 7-days.
  • maxInstanceLifetime can have 0 which is used to clear a previously set value.

Test

  • Run unit test.
PASS test/auto-scaling-group.test.js

=============================== Coverage summary ===============================
Statements   : 93.11% ( 419/450 )
Branches     : 86.93% ( 286/329 )
Functions    : 91.81% ( 101/110 )
Lines        : 92.84% ( 402/433 )
================================================================================
  • Deploy CFN template having maxInstanceLifetime as 86,400 and 0.

Notes

Originally, this issue was reported by #12588.


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use cdk-integ to deploy the infrastructure and generate the snapshot (i.e. cdk-integ without --dry-run)?

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

@gitpod-io
Copy link

gitpod-io bot commented Mar 28, 2022

@github-actions github-actions bot added the @aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling label Mar 28, 2022
@github-actions github-actions bot added the p2 label Mar 28, 2022
@jungseoklee
Copy link
Contributor Author

Originally, a lower bound of maxInstanceLifetime was 7-day: https://aws.amazon.com/about-aws/whats-new/2019/11/amazon-ec2-auto-scaling-supports-max-instance-lifetime/, which makes me wonder if it is better to remove validation and then rely on service itself. The current validation needs to be updated whenever service behavior changes, which not only turns into maintenance overhead, but also blocks CDK user relying on L2 construct.

if (this.maxInstanceLifetime &&
(this.maxInstanceLifetime.toSeconds() < 604800 || this.maxInstanceLifetime.toSeconds() > 31536000)) {
throw new Error('maxInstanceLifetime must be between 7 and 365 days (inclusive)');
(this.maxInstanceLifetime.toSeconds() !== 0) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

You have to also check for this to be unresolved (!this.maxInstanceLifetime.isUnresolved())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will update.

@comcalvi comcalvi removed their assignment Mar 31, 2022
This patch fixes bugs in maxInstanceLifetime validation logic.
@mergify mergify bot dismissed rix0rrr’s stale review April 4, 2022 20:44

Pull request has been modified.

@jungseoklee
Copy link
Contributor Author

Changes since the first revision:

  • Added !this.maxInstanceLifetime.isUnresolved() to the relevant condition.

@mergify
Copy link
Contributor

mergify bot commented Apr 8, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 6b73e24
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot merged commit d115b47 into aws:master Apr 8, 2022
@mergify
Copy link
Contributor

mergify bot commented Apr 8, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

otaviomacedo pushed a commit that referenced this pull request Apr 11, 2022
### Summary

This patch fixes the following bugs in `maxInstanceLifetime` validation by aligning with [CFN doc](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html#cfn-as-group-maxinstancelifetime):

 - A lower bound of `maxInstanceLifetime` is 1 day, not 7-days.
 - `maxInstanceLifetime` can have 0 which is used to clear a previously set value.

### Test

- Run unit test.
```
PASS test/auto-scaling-group.test.js

=============================== Coverage summary ===============================
Statements   : 93.11% ( 419/450 )
Branches     : 86.93% ( 286/329 )
Functions    : 91.81% ( 101/110 )
Lines        : 92.84% ( 402/433 )
================================================================================
```
- Deploy CFN template having `maxInstanceLifetime` as 86,400 and 0.

### Notes

Originally, this issue was reported by #12588.

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
StevePotter pushed a commit to StevePotter/aws-cdk that referenced this pull request Apr 27, 2022
### Summary

This patch fixes the following bugs in `maxInstanceLifetime` validation by aligning with [CFN doc](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html#cfn-as-group-maxinstancelifetime):

 - A lower bound of `maxInstanceLifetime` is 1 day, not 7-days.
 - `maxInstanceLifetime` can have 0 which is used to clear a previously set value.

### Test

- Run unit test.
```
PASS test/auto-scaling-group.test.js

=============================== Coverage summary ===============================
Statements   : 93.11% ( 419/450 )
Branches     : 86.93% ( 286/329 )
Functions    : 91.81% ( 101/110 )
Lines        : 92.84% ( 402/433 )
================================================================================
```
- Deploy CFN template having `maxInstanceLifetime` as 86,400 and 0.

### Notes

Originally, this issue was reported by aws#12588.

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants