-
Notifications
You must be signed in to change notification settings - Fork 5.3k
health check: close conn after timeout/stream rst when grpc hc has conn reuse disabled #11325
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
Merged
mattklein123
merged 4 commits into
envoyproxy:master
from
jmuia:jmuia.grpc-hc-reuse-conn-timeout
Jun 3, 2020
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2a28a40
health check: close conn after timeout/stream rst when grpc hc has co…
jmuia a81e1b9
close connection after logging
jmuia 44126ac
Fix tests after rebasing off master
jmuia a1a656a
Add comments to test cases to clarify the key assertions
jmuia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4487,6 +4487,66 @@ TEST_F(GrpcHealthCheckerImplTest, DontReuseConnectionBetweenChecks) { | |
| expectHostHealthy(true); | ||
| } | ||
|
|
||
| // Test that we close connections when a timeout occurs and reuse_connection is false. | ||
| TEST_F(GrpcHealthCheckerImplTest, DontReuseConnectionTimeout) { | ||
| setupNoReuseConnectionHC(); | ||
| cluster_->prioritySet().getMockHostSet(0)->hosts_ = { | ||
| makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; | ||
|
|
||
| expectSessionCreate(); | ||
| expectHealthcheckStart(0); | ||
| EXPECT_CALL(event_logger_, logUnhealthy(_, _, _, true)); | ||
| health_checker_->start(); | ||
|
|
||
| expectHealthcheckStop(0); | ||
| // Timeouts are considered network failures and make host unhealthy also after 2nd event. | ||
| EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); | ||
| test_sessions_[0]->timeout_timer_->invokeCallback(); | ||
| expectHostHealthy(true); | ||
|
|
||
| // A new client is created because we close the connection | ||
| // when a timeout occurs and connection reuse is disabled. | ||
| expectClientCreate(0); | ||
| expectHealthcheckStart(0); | ||
| test_sessions_[0]->interval_timer_->invokeCallback(); | ||
|
|
||
| expectHealthcheckStop(0); | ||
| // Test host state haven't changed. | ||
| EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); | ||
| respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); | ||
| expectHostHealthy(true); | ||
| } | ||
|
|
||
| // Test that we close connections when a stream reset occurs and reuse_connection is false. | ||
| TEST_F(GrpcHealthCheckerImplTest, DontReuseConnectionStreamReset) { | ||
| setupNoReuseConnectionHC(); | ||
| cluster_->prioritySet().getMockHostSet(0)->hosts_ = { | ||
| makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; | ||
|
|
||
| expectSessionCreate(); | ||
| expectHealthcheckStart(0); | ||
| EXPECT_CALL(event_logger_, logUnhealthy(_, _, _, true)); | ||
| health_checker_->start(); | ||
|
|
||
| expectHealthcheckStop(0); | ||
| // Resets are considered network failures and make host unhealthy also after 2nd event. | ||
| EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); | ||
| test_sessions_[0]->request_encoder_.stream_.resetStream(Http::StreamResetReason::RemoteReset); | ||
| expectHostHealthy(true); | ||
|
|
||
| // A new client is created because we close the connection | ||
| // when a stream reset occurs and connection reuse is disabled. | ||
| expectClientCreate(0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment here |
||
| expectHealthcheckStart(0); | ||
| test_sessions_[0]->interval_timer_->invokeCallback(); | ||
|
|
||
| expectHealthcheckStop(0); | ||
| // Test host state haven't changed. | ||
| EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); | ||
| respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); | ||
| expectHostHealthy(true); | ||
| } | ||
|
|
||
| // Test UNKNOWN health status is considered unhealthy. | ||
| TEST_F(GrpcHealthCheckerImplTest, GrpcFailUnknown) { | ||
| setupHC(); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 a comment to this test case to make it easier to understand which assertion is verifying that we're not reusing the connection? I think its
expectClientCreatebut it would be nice with a comment alongside it