-
Notifications
You must be signed in to change notification settings - Fork 5.3k
admin: support HTML UI for admin post params #22424
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
Changes from all commits
c4101e1
29cf776
94c97c0
aa00670
34c7607
4e821b4
8cbcf36
ff2aaf9
1e4d606
256b6c9
49212f6
ba5a1dc
c78b6a4
33b2f22
efe142e
78091d1
119270c
68a89d2
70ce924
71c1647
d04a05c
85d33f7
d482473
d42f01a
2c4422a
594b618
102d95c
a5706e1
a4de093
246af3a
987e764
5f5ae3c
c9041e6
afbcf1a
3fc02f0
fc5ac30
7bb3a00
6dcac05
81f2763
329281b
c537b80
25c871e
685e307
182c26d
fecece3
f187c65
d16f773
2ec28de
e23c884
4f59d62
c2350a2
c9a0467
e8abc92
bfb734a
752ae63
e8d16fd
abe2049
ab028cf
d9d03c8
b28dd55
1b95d3b
048d239
93fe3f3
5c0fd6c
85cde04
b626917
ddda5d7
2a62570
03be332
ce6e904
26f200d
50dbe5a
0859243
603f0f8
1cc67ca
ee21f74
379b316
a7b3565
c456954
8c3af8b
58c8b81
36888b8
1738fc7
35595ac
c820090
da2db71
4f2025f
bcc798b
8c9d80c
b17ad84
855d881
1c3e458
832ea51
4d7b7e5
f76377b
327ce0f
e6c81a0
8ce26f4
32ce495
4ec9bad
e17e9b4
09ca850
c77f7cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,15 @@ void AdminImpl::startHttpListener(const std::list<AccessLog::InstanceSharedPtr>& | |
| } | ||
| } | ||
|
|
||
| namespace { | ||
| // Prepends an element to an array, modifying it as passed in. | ||
| std::vector<absl::string_view> prepend(const absl::string_view first, | ||
| std::vector<absl::string_view> strings) { | ||
| strings.insert(strings.begin(), first); | ||
| return strings; | ||
| } | ||
| } // namespace | ||
|
|
||
| AdminImpl::AdminImpl(const std::string& profile_path, Server::Instance& server, | ||
| bool ignore_global_conn_limit) | ||
| : server_(server), | ||
|
|
@@ -122,9 +131,17 @@ AdminImpl::AdminImpl(const std::string& profile_path, Server::Instance& server, | |
| makeHandler("/contention", "dump current Envoy mutex contention stats (if enabled)", | ||
| MAKE_ADMIN_HANDLER(stats_handler_.handlerContention), false, false), | ||
| makeHandler("/cpuprofiler", "enable/disable the CPU profiler", | ||
| MAKE_ADMIN_HANDLER(profiling_handler_.handlerCpuProfiler), false, true), | ||
| MAKE_ADMIN_HANDLER(profiling_handler_.handlerCpuProfiler), false, true, | ||
| {{Admin::ParamDescriptor::Type::Enum, | ||
| "enable", | ||
| "enables the CPU profiler", | ||
| {"y", "n"}}}), | ||
| makeHandler("/heapprofiler", "enable/disable the heap profiler", | ||
| MAKE_ADMIN_HANDLER(profiling_handler_.handlerHeapProfiler), false, true), | ||
| MAKE_ADMIN_HANDLER(profiling_handler_.handlerHeapProfiler), false, true, | ||
| {{Admin::ParamDescriptor::Type::Enum, | ||
| "enable", | ||
| "enable/disable the heap profiler", | ||
| {"y", "n"}}}), | ||
| makeHandler("/heap_dump", "dump current Envoy heap (if supported)", | ||
| MAKE_ADMIN_HANDLER(tcmalloc_profiling_handler_.handlerHeapDump), false, | ||
| false), | ||
|
|
@@ -138,20 +155,34 @@ AdminImpl::AdminImpl(const std::string& profile_path, Server::Instance& server, | |
| MAKE_ADMIN_HANDLER(server_info_handler_.handlerHotRestartVersion), false, | ||
| false), | ||
|
|
||
| // TODO(jmarantz): add support for param-passing through a POST. Browsers send | ||
| // those params as the post-body rather than query-params and that requires some | ||
| // re-plumbing through the admin callback API. See also drain_listeners. | ||
| // The logging "level" parameter, if specified as a non-blank entry, | ||
| // changes all the logging-paths to that level. So the enum parameter | ||
| // needs to include a an empty string as the default (first) option. | ||
| // Thus we prepend an empty string to the logging-levels list. | ||
| makeHandler("/logging", "query/change logging levels", | ||
| MAKE_ADMIN_HANDLER(logs_handler_.handlerLogging), false, true), | ||
|
|
||
| MAKE_ADMIN_HANDLER(logs_handler_.handlerLogging), false, true, | ||
| {{Admin::ParamDescriptor::Type::String, "paths", | ||
| "Change multiple logging levels by setting to " | ||
| "<logger_name1>:<desired_level1>,<logger_name2>:<desired_level2>."}, | ||
| {Admin::ParamDescriptor::Type::Enum, "level", "desired logging level", | ||
| prepend("", LogsHandler::levelStrings())}}), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does empty level do? I could not find this info here https://www.envoyproxy.io/docs/envoy/latest/operations/admin#post--logging
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this particular command, if you specify one of the logging levels, it will change all the logging paths to use that level. If you leave the level blank then it will perform some other operation -- either just listing out the current levels for each path, or setting particular path/level combos. I'll add a comment. |
||
| makeHandler("/memory", "print current allocation/heap usage", | ||
| MAKE_ADMIN_HANDLER(server_info_handler_.handlerMemory), false, false), | ||
| makeHandler("/quitquitquit", "exit the server", | ||
| MAKE_ADMIN_HANDLER(server_cmd_handler_.handlerQuitQuitQuit), false, true), | ||
| makeHandler("/reset_counters", "reset all counters to zero", | ||
| MAKE_ADMIN_HANDLER(stats_handler_.handlerResetCounters), false, true), | ||
| makeHandler("/drain_listeners", "drain listeners", | ||
| MAKE_ADMIN_HANDLER(listeners_handler_.handlerDrainListeners), false, true), | ||
| makeHandler( | ||
| "/drain_listeners", "drain listeners", | ||
| MAKE_ADMIN_HANDLER(listeners_handler_.handlerDrainListeners), false, true, | ||
| {{ParamDescriptor::Type::Boolean, "graceful", | ||
| "When draining listeners, enter a graceful drain period prior to closing " | ||
| "listeners. This behaviour and duration is configurable via server options " | ||
| "or CLI"}, | ||
| {ParamDescriptor::Type::Boolean, "inboundonly", | ||
| "Drains all inbound listeners. traffic_direction field in " | ||
| "envoy_v3_api_msg_config.listener.v3.Listener is used to determine whether a " | ||
| "listener is inbound or outbound."}}), | ||
| makeHandler("/server_info", "print server version/status information", | ||
| MAKE_ADMIN_HANDLER(server_info_handler_.handlerServerInfo), false, false), | ||
| makeHandler("/ready", "print server state, return 200 if LIVE, otherwise return 503", | ||
|
|
@@ -335,6 +366,7 @@ Admin::RequestPtr AdminImpl::makeRequest(absl::string_view path_and_query, | |
| } | ||
| } | ||
|
|
||
| ASSERT(admin_stream.getRequestHeaders().getPathValue() == path_and_query); | ||
| return handler.handler_(path_and_query, admin_stream); | ||
| } | ||
| } | ||
|
|
@@ -369,7 +401,8 @@ void AdminImpl::getHelp(Buffer::Instance& response) const { | |
|
|
||
| // Prefix order is used during searching, but for printing do them in alpha order. | ||
| for (const UrlHandler* handler : sortedHandlers()) { | ||
| response.add(fmt::format(" {}: {}\n", handler->prefix_, handler->help_text_)); | ||
| const absl::string_view method = handler->mutates_server_state_ ? " (POST)" : ""; | ||
| response.add(fmt::format(" {}{}: {}\n", handler->prefix_, method, handler->help_text_)); | ||
| for (const ParamDescriptor& param : handler->params_) { | ||
| response.add(fmt::format(" {}: {}", param.id_, param.help_)); | ||
| if (param.type_ == ParamDescriptor::Type::Enum) { | ||
|
|
@@ -440,6 +473,7 @@ Http::Code AdminImpl::request(absl::string_view path_and_query, absl::string_vie | |
|
|
||
| auto request_headers = Http::RequestHeaderMapImpl::create(); | ||
| request_headers->setMethod(method); | ||
| request_headers->setPath(path_and_query); | ||
| filter.decodeHeaders(*request_headers, false); | ||
| Buffer::OwnedImpl response; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.