Skip to content
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
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Bug Fixes
---------
*Changes expected to improve the state of the world and are unlikely to have negative effects*

* access log: fix `%UPSTREAM_CLUSTER%` when used in http upstream access logs. Previously, it was always logging as an unset value.
* xray: fix the AWS X-Ray tracer bug where span's error, fault and throttle information was not reported properly as per the `AWS X-Ray documentation <https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html>`_. Before this fix, server error was reported under 'annotations' section of the segment data.

Removed Config or Runtime
Expand Down
5 changes: 5 additions & 0 deletions source/common/router/upstream_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ UpstreamRequest::UpstreamRequest(RouterFilterInterface& parent,
}

stream_info_.healthCheck(parent_.callbacks()->streamInfo().healthCheck());
absl::optional<Upstream::ClusterInfoConstSharedPtr> cluster_info =
parent_.callbacks()->streamInfo().upstreamClusterInfo();
if (cluster_info.has_value()) {
stream_info_.setUpstreamClusterInfo(*cluster_info);
}
}

UpstreamRequest::~UpstreamRequest() {
Expand Down
30 changes: 30 additions & 0 deletions test/common/router/router_upstream_log_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ class RouterUpstreamLogTest : public testing::Test {
public:
void init(absl::optional<envoy::config::accesslog::v3::AccessLog> upstream_log) {
envoy::extensions::filters::http::router::v3::Router router_proto;
static const std::string cluster_name = "cluster_0";

cluster_info_ = std::make_shared<NiceMock<Upstream::MockClusterInfo>>();
ON_CALL(*cluster_info_, name()).WillByDefault(ReturnRef(cluster_name));
ON_CALL(*cluster_info_, observabilityName()).WillByDefault(ReturnRef(cluster_name));
ON_CALL(callbacks_.stream_info_, upstreamClusterInfo()).WillByDefault(Return(cluster_info_));

if (upstream_log) {
ON_CALL(*context_.access_log_manager_.file_, write(_))
Expand Down Expand Up @@ -160,6 +166,7 @@ class RouterUpstreamLogTest : public testing::Test {

EXPECT_CALL(context_.cluster_manager_.thread_local_cluster_.conn_pool_.host_->outlier_detector_,
putHttpResponseCode(response_code));
// NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage)
response_decoder->decodeHeaders(std::move(response_headers), false);

Http::ResponseTrailerMapPtr response_trailers(
Expand Down Expand Up @@ -245,6 +252,7 @@ class RouterUpstreamLogTest : public testing::Test {
NiceMock<Http::MockStreamDecoderFilterCallbacks> callbacks_;
std::shared_ptr<FilterConfig> config_;
std::shared_ptr<TestFilter> router_;
std::shared_ptr<NiceMock<Upstream::MockClusterInfo>> cluster_info_;
NiceMock<StreamInfo::MockStreamInfo> stream_info_;
};

Expand Down Expand Up @@ -365,5 +373,27 @@ name: accesslog
EXPECT_EQ(output_.front(), "110 49 41");
}

// Test UPSTREAM_CLUSTER log formatter.
TEST_F(RouterUpstreamLogTest, UpstreamCluster) {
const std::string yaml = R"EOF(
name: accesslog
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
log_format:
text_format_source:
inline_string: "%UPSTREAM_CLUSTER%"
path: "/dev/null"
)EOF";

envoy::config::accesslog::v3::AccessLog upstream_log;
TestUtility::loadFromYaml(yaml, upstream_log);

init(absl::optional<envoy::config::accesslog::v3::AccessLog>(upstream_log));
run();

EXPECT_EQ(output_.size(), 1U);
EXPECT_EQ(output_.front(), "cluster_0");
}

} // namespace Router
} // namespace Envoy