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

feat(applicationautoscaling): validate evaluationPeriods and datapointsToAlarm for step scaling policy #28880

Merged
merged 5 commits into from
Jan 30, 2024

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Jan 26, 2024

This PR adds validations for evaluationPeriods and datapointsToAlarm for step scaling policy. It is based on the PR for datapointsToAlarm in autoscaling step scaling policy.

Check the following cases:

  • evaluationPeriods < 1
  • datapointsToAlarm is set, and
    • evaluationPeriods is not set
    • datapointsToAlarm < 1
    • evaluationPeriods < datapointsToAlarm

These validations also consider whether those parameters are tokens or not.


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

@github-actions github-actions bot added the p2 label Jan 26, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team January 26, 2024 16:04
@github-actions github-actions bot added the distinguished-contributor [Pilot] contributed 50+ PRs to the CDK label Jan 26, 2024
@go-to-k go-to-k changed the title feat(applicationautoscaling): add validations for evaluationPeriods and datapointsToAlarm feat(applicationautoscaling): validate evaluationPeriods and datapointsToAlarm for step scaling policy Jan 26, 2024
@go-to-k go-to-k changed the title feat(applicationautoscaling): validate evaluationPeriods and datapointsToAlarm for step scaling policy feat(applicationautoscaling): validate evaluationPeriods and datapointsToAlarm for step scaling policy Jan 26, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@go-to-k
Copy link
Contributor Author

go-to-k commented Jan 26, 2024

Exemption Request: This PR just adds validations, so the unit tests could cover.

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Jan 26, 2024
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

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

Thanks 👍
Just a small nit.
Also, I think we can consider this a chore.

}
if (props.datapointsToAlarm !== undefined) {
if (props.evaluationPeriods === undefined) {
throw new RangeError('evaluationPeriods must be set if datapointsToAlarm is set');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
throw new RangeError('evaluationPeriods must be set if datapointsToAlarm is set');
throw new Error('evaluationPeriods must be set if datapointsToAlarm is set');

Should be a simple Error.
In general, I don't see RangeErrors being used much in the repo.
I'm wondering if it wouldn't just be better to use the Error class for all guards in this file as well 🤔

Copy link
Contributor Author

@go-to-k go-to-k Jan 29, 2024

Choose a reason for hiding this comment

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

OK, I have adapted the existing code as it is not the essence of this PR, but I will change all RangeErrors to Error.

@go-to-k go-to-k changed the title feat(applicationautoscaling): validate evaluationPeriods and datapointsToAlarm for step scaling policy chore(applicationautoscaling): validate evaluationPeriods and datapointsToAlarm for step scaling policy Jan 29, 2024
@go-to-k
Copy link
Contributor Author

go-to-k commented Jan 29, 2024

@lpizzinidev

Thanks for your review. I changed the RangeError and PR title.

Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@paulhcsun paulhcsun added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Jan 30, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 30, 2024 00:08

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Jan 30, 2024
@kaizencc kaizencc changed the title chore(applicationautoscaling): validate evaluationPeriods and datapointsToAlarm for step scaling policy feat(applicationautoscaling): validate evaluationPeriods and datapointsToAlarm for step scaling policy Jan 30, 2024
@kaizencc kaizencc removed the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Jan 30, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 30, 2024
@paulhcsun paulhcsun added the pr-linter/exempt-readme The PR linter will not require README changes label Jan 30, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 30, 2024 19:56

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 224dca6
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

Copy link
Contributor

mergify bot commented Jan 30, 2024

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

@mergify mergify bot merged commit 4034adb into aws:main Jan 30, 2024
11 checks passed
SankyRed pushed a commit that referenced this pull request Feb 8, 2024
…ointsToAlarm` for step scaling policy (#28880)

This PR adds validations for `evaluationPeriods` and `datapointsToAlarm` for step scaling policy. It is based on [the PR for datapointsToAlarm in autoscaling step scaling policy](#28792).

Check the following cases:
- `evaluationPeriods` < 1
- `datapointsToAlarm` is set, and
  - `evaluationPeriods` is not set
  - `datapointsToAlarm` < 1
  - `evaluationPeriods` < `datapointsToAlarm`

These validations also consider whether those parameters are tokens or not.

----

*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
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants