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

use route directive regardless of rpc status #2087

Merged
merged 2 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions src/envoy/http/mixer/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,33 +155,40 @@ void Filter::completeCheck(const CheckResponseInfo& info) {
return;
}

route_directive_ = info.route_directive;

// set UAEX access log flag
if (!status.ok()) {
state_ = Responded;
int status_code = ::istio::utils::StatusHttpCode(status.error_code());
decoder_callbacks_->sendLocalReply(Code(status_code), status.ToString(),
nullptr, absl::nullopt);
decoder_callbacks_->streamInfo().setResponseFlag(
StreamInfo::ResponseFlag::UnauthorizedExternalService);
return;
}

state_ = Complete;
route_directive_ = info.route_directive;

// handle direct response from the route directive
if (status.ok() && route_directive_.direct_response_code() != 0) {
ENVOY_LOG(debug, "Mixer::Filter direct response");
if (route_directive_.direct_response_code() != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

does this mean we respond with LocalReply even when status is not ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is direct response code, yes. Normally, it's not set. If there is an error detail, Mixer will set it for the error case.

int status_code = route_directive_.direct_response_code();
ENVOY_LOG(debug, "Mixer::Filter direct response {}", status_code);
state_ = Responded;
decoder_callbacks_->sendLocalReply(
Code(route_directive_.direct_response_code()),
route_directive_.direct_response_body(),
Code(status_code), route_directive_.direct_response_body(),
[this](HeaderMap& headers) {
UpdateHeaders(headers, route_directive_.response_header_operations());
},
absl::nullopt);
return;
}

// create a local reply for status not OK even if there is no direct response
if (!status.ok()) {
state_ = Responded;

int status_code = ::istio::utils::StatusHttpCode(status.error_code());
decoder_callbacks_->sendLocalReply(Code(status_code), status.ToString(),
nullptr, absl::nullopt);
return;
}

state_ = Complete;

// handle request header operations
if (nullptr != headers_) {
UpdateHeaders(*headers_, route_directive_.request_header_operations());
Expand Down
2 changes: 1 addition & 1 deletion src/istio/mixerclient/check_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CheckCache {
// Check status.
::google::protobuf::util::Status status_;

// Route directive (if status is OK).
// Route directive
::istio::mixer::v1::RouteDirective route_directive_;

// The function to set check response.
Expand Down