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

admin: fix /server_info hot restart version #8022

Merged
merged 5 commits into from
Aug 26, 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
6 changes: 4 additions & 2 deletions api/envoy/admin/v2alpha/server_info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ message ServerInfo {
// Uptime since the start of the first epoch.
google.protobuf.Duration uptime_all_epochs = 4;

// Hot restart version.
string hot_restart_version = 5;
Copy link
Member

Choose a reason for hiding this comment

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

Since this is v2alpha, you have API sign-off.


// Command line options the server is currently running with.
CommandLineOptions command_line_options = 6;
}
Expand Down Expand Up @@ -82,8 +85,7 @@ message CommandLineOptions {
// See :option:`--log-path` for details.
string log_path = 11;

// See :option:`--hot-restart-version` for details.
bool hot_restart_version = 12;
reserved 12;

// See :option:`--service-cluster` for details.
string service_cluster = 13;
Expand Down
1 change: 1 addition & 0 deletions source/server/http/admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ Http::Code AdminImpl::handlerServerInfo(absl::string_view, Http::HeaderMap& head
time_t current_time = time(nullptr);
envoy::admin::v2alpha::ServerInfo server_info;
server_info.set_version(VersionInfo::version());
server_info.set_hot_restart_version(server_.hotRestart().version());
server_info.set_state(
Utility::serverState(server_.initManager().state(), server_.healthCheckFailed()));

Expand Down
2 changes: 2 additions & 0 deletions test/server/http/admin_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,7 @@ TEST_P(AdminInstanceTest, GetRequest) {
}));
NiceMock<Init::MockManager> initManager;
ON_CALL(server_, initManager()).WillByDefault(ReturnRef(initManager));
ON_CALL(server_.hot_restart_, version()).WillByDefault(Return("foo_version"));

{
Http::HeaderMapImpl response_headers;
Expand All @@ -1254,6 +1255,7 @@ TEST_P(AdminInstanceTest, GetRequest) {
// values such as timestamps + Envoy version are tricky to test for.
TestUtility::loadFromJson(body, server_info_proto);
EXPECT_EQ(server_info_proto.state(), envoy::admin::v2alpha::ServerInfo::LIVE);
EXPECT_EQ(server_info_proto.hot_restart_version(), "foo_version");
EXPECT_EQ(server_info_proto.command_line_options().restart_epoch(), 2);
EXPECT_EQ(server_info_proto.command_line_options().service_cluster(), "cluster");
}
Expand Down
5 changes: 3 additions & 2 deletions test/server/options_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,15 @@ TEST_F(OptionsImplTest, OptionsAreInSyncWithProto) {
Server::CommandLineOptionsPtr command_line_options = options->toCommandLineOptions();
// Failure of this condition indicates that the server_info proto is not in sync with the options.
// If an option is added/removed, please update server_info proto as well to keep it in sync.
// Currently the following 5 options are not defined in proto, hence the count differs by 5.
// Currently the following 7 options are not defined in proto, hence the count differs by 7.
// 1. version - default TCLAP argument.
// 2. help - default TCLAP argument.
// 3. ignore_rest - default TCLAP argument.
// 4. use-libevent-buffers - short-term override for rollout of new buffer implementation.
// 5. allow-unknown-fields - deprecated alias of allow-unknown-static-fields.
// 6. use-fake-symbol-table - short-term override for rollout of real symbol-table implementation.
EXPECT_EQ(options->count() - 6, command_line_options->GetDescriptor()->field_count());
// 7. hot restart version - print the hot restart version and exit.
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why this doesn't sync?

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean?

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why this option isn't defined in the proto as per this test comment? It's defined above! :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this option from the proto. It's a CLI option that forces Envoy to exit and print the hot restart version, thus it would never be set to true, so it makes no sense. I moved this output to ServerInfo...

EXPECT_EQ(options->count() - 7, command_line_options->GetDescriptor()->field_count());
}

TEST_F(OptionsImplTest, BadCliOption) {
Expand Down