-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
Exemption request: I'm adding a validation for parameters. Shouldn't need an integration test here. |
There was a problem hiding this 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()}'`); | |||
} |
There was a problem hiding this comment.
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
There was a problem hiding this 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 ' + |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 <
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
dffea61
to
af8d3e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM
@kaizencc could I have a review here please ? |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
There was a problem hiding this 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', () => { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
Closes #29062.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license