-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Outlier Detection: use gRPC status code for detecting failures #7942
Merged
mattklein123
merged 12 commits into
envoyproxy:master
from
ZhouyihaiDing:outlier_detection_grpc_status
Sep 7, 2019
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9352c0b
[Outlier Detection] Replace HTTP status with gRPC status
ZhouyihaiDing 1aa2211
small change for c++ readability
ZhouyihaiDing b06bc2e
remove grpc_status_code_received_
ZhouyihaiDing f0a2c06
Update the PR which supports the grpc-status from init-metadata
ZhouyihaiDing e473294
Remove the change for statistics
ZhouyihaiDing dd768d1
Parse grpc status once per onUpstreamHeaders
ZhouyihaiDing 107ae87
Add comment and fix nit
ZhouyihaiDing 88955c7
Merge branch 'master' of https://github.com/envoyproxy/envoy into out…
ZhouyihaiDing 8477a71
Add runtime guarding "outlier_detection_support_for_grpc_status"
ZhouyihaiDing 7453108
Add release note and update the outlier detection document
ZhouyihaiDing 595dc55
Update document: add gRPC sub-section, fix link. Add comments to tests
ZhouyihaiDing d69314c
Ref-link the release note to the outlier detection grpc sub-section
ZhouyihaiDing 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 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 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 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 |
---|---|---|
|
@@ -1199,6 +1199,31 @@ TEST_F(RouterTest, GrpcAlreadyExistsTrailersOnly) { | |
EXPECT_TRUE(verifyHostUpstreamStats(1, 0)); | ||
} | ||
|
||
// Validate outlier detections records failure when gRPC response status is Unavailable. | ||
TEST_F(RouterTest, GrpcOutlierDetectionUnavailableStatusCode) { | ||
NiceMock<Http::MockStreamEncoder> encoder1; | ||
Http::StreamDecoder* response_decoder = nullptr; | ||
EXPECT_CALL(cm_.conn_pool_, newStream(_, _)) | ||
.WillOnce(Invoke([&](Http::StreamDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) | ||
-> Http::ConnectionPool::Cancellable* { | ||
response_decoder = &decoder; | ||
callbacks.onPoolReady(encoder1, cm_.conn_pool_.host_); | ||
return nullptr; | ||
})); | ||
expectResponseTimerCreate(); | ||
|
||
Http::TestHeaderMapImpl headers{{"content-type", "application/grpc"}, {"grpc-timeout", "20S"}}; | ||
HttpTestUtility::addDefaultHeaders(headers); | ||
router_.decodeHeaders(headers, true); | ||
|
||
Http::HeaderMapPtr response_headers( | ||
new Http::TestHeaderMapImpl{{":status", "200"}, {"grpc-status", "14"}}); | ||
// Outlier detector will use the gRPC response status code. | ||
EXPECT_CALL(cm_.conn_pool_.host_->outlier_detector_, putHttpResponseCode(503)); | ||
response_decoder->decodeHeaders(std::move(response_headers), true); | ||
EXPECT_TRUE(verifyHostUpstreamStats(0, 1)); | ||
} | ||
ZhouyihaiDing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Validate gRPC Internal response stats are sane when response is trailers only. | ||
TEST_F(RouterTest, GrpcInternalTrailersOnly) { | ||
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. Need comment. 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. Done. |
||
NiceMock<Http::MockStreamEncoder> encoder1; | ||
|
@@ -1218,7 +1243,7 @@ TEST_F(RouterTest, GrpcInternalTrailersOnly) { | |
|
||
Http::HeaderMapPtr response_headers( | ||
new Http::TestHeaderMapImpl{{":status", "200"}, {"grpc-status", "13"}}); | ||
EXPECT_CALL(cm_.conn_pool_.host_->outlier_detector_, putHttpResponseCode(200)); | ||
EXPECT_CALL(cm_.conn_pool_.host_->outlier_detector_, putHttpResponseCode(500)); | ||
response_decoder->decodeHeaders(std::move(response_headers), true); | ||
EXPECT_TRUE(verifyHostUpstreamStats(0, 1)); | ||
} | ||
|
@@ -1326,10 +1351,10 @@ TEST_F(RouterTest, GrpcInternal) { | |
router_.decodeHeaders(headers, true); | ||
|
||
Http::HeaderMapPtr response_headers(new Http::TestHeaderMapImpl{{":status", "200"}}); | ||
EXPECT_CALL(cm_.conn_pool_.host_->outlier_detector_, putHttpResponseCode(200)); | ||
response_decoder->decodeHeaders(std::move(response_headers), false); | ||
EXPECT_TRUE(verifyHostUpstreamStats(0, 0)); | ||
Http::HeaderMapPtr response_trailers(new Http::TestHeaderMapImpl{{"grpc-status", "13"}}); | ||
EXPECT_CALL(cm_.conn_pool_.host_->outlier_detector_, putHttpResponseCode(500)); | ||
response_decoder->decodeTrailers(std::move(response_trailers)); | ||
EXPECT_TRUE(verifyHostUpstreamStats(0, 1)); | ||
} | ||
|
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.
is this future proof, e.g. 4xx codes will never have the same issue 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.
From outlier_detection.proto, outlier only cares about 5xx status code.
For non-5xx gRPC status code, we use the http status code instead so non-5xx failure's behavior remains unchanged.
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 think you should clarify the intent of this change as
"For gRPC requests, we overwrite the default (200) status for the outlier detector only when the grpc status maps to 5xx HTTP status. TODO: confirm if 4xx status should be recorded with the outlier detector."
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 think it's fine to only consider 5xx today, but can we future proof by always doing
grpcToHttpStatus
? Shouldn't it be idempotent for 200?