Skip to content

Commit

Permalink
Log actual admin port. (#16197)
Browse files Browse the repository at this point in the history
Signed-off-by: Manish Kumar <[email protected]>
  • Loading branch information
Manish Kumar authored Apr 28, 2021
1 parent c75ac18 commit 55e858a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions source/server/admin/admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void AdminImpl::startHttpListener(const std::list<AccessLog::InstanceSharedPtr>&
socket_ = std::make_shared<Network::TcpListenSocket>(address, socket_options, true);
socket_factory_ = std::make_shared<AdminListenSocketFactory>(socket_);
listener_ = std::make_unique<AdminListener>(*this, std::move(listener_scope));
ENVOY_LOG(info, "admin address: {}", socket().addressProvider().localAddress()->asString());
if (!address_out_path.empty()) {
std::ofstream address_out_file(address_out_path);
if (!address_out_file) {
Expand Down
1 change: 0 additions & 1 deletion source/server/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ void InstanceImpl::initialize(const Options& options,
}

if (initial_config.admin().address()) {
ENVOY_LOG(info, "admin address: {}", initial_config.admin().address()->asString());
admin_->startHttpListener(initial_config.admin().accessLogs(), options.adminAddressPath(),
initial_config.admin().address(),
initial_config.admin().socketOptions(),
Expand Down
15 changes: 15 additions & 0 deletions test/server/admin/admin_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ TEST_P(AdminInstanceTest, WriteAddressToFile) {
EXPECT_EQ(admin_.socket().addressProvider().localAddress()->asString(), address_from_file);
}

TEST_P(AdminInstanceTest, AdminAddress) {
std::string address_out_path = TestEnvironment::temporaryPath("admin.address");
AdminImpl admin_address_out_path(cpu_profile_path_, server_);
std::list<AccessLog::InstanceSharedPtr> access_logs;
Filesystem::FilePathAndType file_info{Filesystem::DestinationType::File, "/dev/null"};
access_logs.emplace_back(new Extensions::AccessLoggers::File::FileAccessLog(
file_info, {}, Formatter::SubstitutionFormatUtils::defaultSubstitutionFormatter(),
server_.accessLogManager()));
EXPECT_LOG_CONTAINS("info", "admin address:",
admin_address_out_path.startHttpListener(
access_logs, address_out_path,
Network::Test::getCanonicalLoopbackAddress(GetParam()), nullptr,
listener_scope_.createScope("listener.admin.")));
}

TEST_P(AdminInstanceTest, AdminBadAddressOutPath) {
std::string bad_path = TestEnvironment::temporaryPath("some/unlikely/bad/path/admin.address");
AdminImpl admin_bad_address_out_path(cpu_profile_path_, server_);
Expand Down

0 comments on commit 55e858a

Please sign in to comment.