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(elasticloadbalancingv2): health check interval greater than timeout #29075

Merged
merged 9 commits into from
Mar 8, 2024

Conversation

msambol
Copy link
Contributor

@msambol msambol commented Feb 12, 2024

Closes #29062.


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 bug This issue is a bug. p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK labels Feb 12, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team February 12, 2024 00:04
@msambol
Copy link
Contributor Author

msambol commented Feb 12, 2024

Exemption request: I'm adding a validation for parameters. Shouldn't need an integration test here.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Feb 12, 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.

@@ -280,9 +280,6 @@ export class NetworkTargetGroup extends TargetGroupBase implements INetworkTarge
if (timeoutSeconds < lowHealthCheckTimeout || timeoutSeconds > highHealthCheckTimeout) {
ret.push(`Health check timeout '${timeoutSeconds}' not supported. Must be a number between ${lowHealthCheckTimeout} and ${highHealthCheckTimeout}.`);
}
if (healthCheck.interval && healthCheck.interval.toSeconds() < timeoutSeconds) {
ret.push(`Health check timeout '${timeoutSeconds}' must not be greater than the interval '${healthCheck.interval.toSeconds()}'`);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moving this validation to shared

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Feb 12, 2024
Copy link
Contributor

@tmokmss tmokmss left a comment

Choose a reason for hiding this comment

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

LGTM overall, with a few minor comment.


if (intervalSeconds && timeoutSeconds) {
if (intervalSeconds < timeoutSeconds) {
ret.push('Health check interval must be greater than the timeout; received interval ' +
Copy link
Contributor

Choose a reason for hiding this comment

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

must be greater than

shouldn't the validation be intervalSeconds <= timeoutSeconds then? A link to the doc (in PR comment) stating this constraint will help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a link to the doc. should be <.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the link.

Timeout
This value must be less than the Interval value.

So we shouldn't allow the case when intervalSeconds == timeoutSeconds. Then the condition should be intervalSeconds <= timeoutSeconds

Copy link
Contributor Author

@msambol msambol Feb 26, 2024

Choose a reason for hiding this comment

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

@tmokmss I removed the doc link. That link is actually for Classic Load Balancers. I think you're correct in that it's intervalSeconds <= timeoutSeconds but the old code for NLBs (I moved it to shared above) has <. Thoughts? It doesn't say this anywhere in the docs but if you look at the issue the errors says: Health check interval must be greater than the timeout.

Copy link
Contributor

@tmokmss tmokmss Feb 26, 2024

Choose a reason for hiding this comment

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

The PR introduced the validation #26031 also described the requirement as below:

Ensure that HealthCheckTimeoutSeconds is not greater than HealthCheckIntervalSeconds.

So I guess it was just a mistake? edit) No, the original implementation matches the comment.

Ideally we should try the configuration (interval==timeout) both for ALB and NLB and it emits the same error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Take a look here: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/nlb/target-group.test.ts#L386-L409. We have a specific test to not throw an error when they're the same. Confusing!

@pahud Is this something you could ask the AWS team about? It would be nice to have this added to the AWS documentation, and then we can decide which way the code needs to be.

Copy link
Contributor

Choose a reason for hiding this comment

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

There was actually a similar discussion in the PR: #26031 (comment)

So I guess we should keep the validation intervalSeconds < timeoutSeconds, and update the comment to e.g. must be greater than or equal to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed back to < and added a note. Thanks, @tmokmss 👍🏼

const intervalSeconds = this.healthCheck.interval?.toSeconds();
const timeoutSeconds = this.healthCheck.timeout?.toSeconds();

if (intervalSeconds && timeoutSeconds) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this work as expected if either intervalSeconds or timeoutSeconds equals to zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

HealthCheckTimeoutSeconds has a range of 2-120 and HealthCheckIntervalSeconds is 5-300. We have separate checks on the ranges, so they'll never be 0.

Copy link
Contributor

@tmokmss tmokmss left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@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 Feb 28, 2024
@msambol
Copy link
Contributor Author

msambol commented Mar 6, 2024

@kaizencc could I have a review here please ?

@paulhcsun paulhcsun added 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 labels Mar 8, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 8, 2024 00:25

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

Copy link
Contributor

@paulhcsun paulhcsun left a comment

Choose a reason for hiding this comment

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

Code changes look good, just left one comment about adding an additional test for the edge case.

@@ -144,6 +144,25 @@ describe('tests', () => {
}).toThrow(/Health check interval '3' not supported. Must be between 5 and 300./);
});

test('Throws error for health check interval less than timeout', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add an edge case test for interval == timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a test for this. See discussion above on why we chose to allow them to be equal.

Copy link
Contributor

@paulhcsun paulhcsun left a comment

Choose a reason for hiding this comment

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

Nice work @msambol! Thanks for the contribution. And thank you @tmokmss for the review!

Copy link
Contributor

mergify bot commented Mar 8, 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).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 7e84d68
  • 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 576d034 into aws:main Mar 8, 2024
9 checks passed
Copy link
Contributor

mergify bot commented Mar 8, 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).

@msambol msambol deleted the 29062 branch March 8, 2024 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member 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 pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-ecs-patterns: Health Check Interval > Timeout Fails On Deploy
4 participants