Skip to content

Commit

Permalink
Fix /server_info (envoyproxy#4966)
Browse files Browse the repository at this point in the history
When `/server_info` changed from a string to JSON we forgot
to populate the restart epoch.

Signed-off-by: Raul Gutierrez Segales <rgs@pinterest.com>
  • Loading branch information
rgs1 authored and mattklein123 committed Nov 6, 2018
1 parent ee036e3 commit 4ef8562
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/server/http/admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ Http::Code AdminImpl::handlerServerInfo(absl::string_view, Http::HeaderMap& head
server_.startTimeCurrentEpoch());
server_info.mutable_uptime_all_epochs()->set_seconds(current_time -
server_.startTimeFirstEpoch());
server_info.set_epoch(server_.options().restartEpoch());
response.add(MessageUtil::getJsonStringFromMessage(server_info, true, true));
headers.insertContentType().value().setReference(Http::Headers::get().ContentTypeValues.Json);
return Http::Code::OK;
Expand Down
4 changes: 4 additions & 0 deletions test/server/http/admin_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,9 @@ TEST_P(AdminInstanceTest, ClustersJson) {
TEST_P(AdminInstanceTest, GetRequest) {
Http::HeaderMapImpl response_headers;
std::string body;

EXPECT_CALL(server_.options_, restartEpoch()).WillOnce(Return(2));

EXPECT_EQ(Http::Code::OK, admin_.request("/server_info", "GET", response_headers, body));
envoy::admin::v2alpha::ServerInfo server_info_proto;
EXPECT_THAT(std::string(response_headers.ContentType()->value().getStringView()),
Expand All @@ -1105,6 +1108,7 @@ TEST_P(AdminInstanceTest, GetRequest) {
// values such as timestamps + Envoy version are tricky to test for.
MessageUtil::loadFromJson(body, server_info_proto);
EXPECT_EQ(server_info_proto.state(), envoy::admin::v2alpha::ServerInfo::LIVE);
EXPECT_EQ(server_info_proto.epoch(), 2);
}

TEST_P(AdminInstanceTest, GetRequestJson) {
Expand Down

0 comments on commit 4ef8562

Please sign in to comment.