Issue 596: Add profiler path to configuration#603
Issue 596: Add profiler path to configuration#603mattklein123 merged 8 commits intoenvoyproxy:masterfrom
Conversation
htuch
left a comment
There was a problem hiding this comment.
Overall, looks great. Mostly minor comments.
| */ | ||
| virtual const std::string& accessLogPath() PURE; | ||
|
|
||
| /** |
There was a problem hiding this comment.
Actually, it might be more semantically correct to call this profilePath (and similar renames elsewhere). It's where the profile is emitted, not the profiler itself. The comment might then be "@return const std::string& profiler output path."
source/common/json/config_schemas.cc
Outdated
| "type" : "object", | ||
| "properties" : { | ||
| "access_log_path" : {"type" : "string"}, | ||
| "profiler_path" : {"type" : "string"}, |
There was a problem hiding this comment.
When you change config_schemas.cc, it's usually also necessary to update the user configuration docs. In this case, the file to update is https://github.com/lyft/envoy/blob/master/docs/configuration/overview/admin.rst.
There was a problem hiding this comment.
You can also defer the config_schemas.cc change to your next PR, since it's not used yet here.
| * Start the profiler and write to the specified path. | ||
| */ | ||
| static void startProfiler(const std::string& output_path); | ||
| static bool startProfiler(const std::string& output_path); |
There was a problem hiding this comment.
Add some return value documentation.
source/server/http/admin.cc
Outdated
| MAKE_HANDLER(handlerServerInfo)}, | ||
| {"/stats", "print server stats", MAKE_HANDLER(handlerStats)}} { | ||
|
|
||
| profiler_path_ = profiler_path; |
There was a problem hiding this comment.
It might be nicer to initialize this in the above constructor member initialization list, i.e.
: server_(server), ..., profiler_path_(profiler_path)
| EXPECT_TRUE(response->complete()); | ||
| EXPECT_STREQ("400", response->headers().Status()->value().c_str()); | ||
|
|
||
| // TO DO: Change to expect 200 when profiler path is a configurable parameter |
There was a problem hiding this comment.
The convention used in Envoy is TODO(hennna): foo bar.
source/server/http/admin.cc
Outdated
| Profiler::Cpu::startProfiler("/var/log/envoy/envoy.prof"); | ||
| if (!Profiler::Cpu::startProfiler(profiler_path_)) { | ||
| response.add("?enable=<y|n>\n"); | ||
| return Http::Code::BadRequest; |
There was a problem hiding this comment.
This returns a 400. I think it's not actually a bad client formed request, it's an internal server error, so you want to return a 500.
source/server/http/admin.cc
Outdated
| if (enable && !Profiler::Cpu::profilerEnabled()) { | ||
| Profiler::Cpu::startProfiler("/var/log/envoy/envoy.prof"); | ||
| if (!Profiler::Cpu::startProfiler(profiler_path_)) { | ||
| response.add("?enable=<y|n>\n"); |
There was a problem hiding this comment.
I think a more meaningful response would indicate there was a failure to start the profiler.
test/server/http/admin_test.cc
Outdated
|
|
||
| NiceMock<MockInstance> server_; | ||
| AdminImpl admin_; | ||
| AdminImpl admin_bad_profiler_path_; |
There was a problem hiding this comment.
I don't think this needs to be a member of AdminFilterTest, it can be just allocated and instantiated locally in AdminBadProfiler.
| // TODO(mattklein123): Switch to mocks and do not bind to a real port. | ||
| AdminFilterTest() | ||
| : admin_("/dev/null", Network::Utility::resolveUrl("tcp://127.0.0.1:9002"), server_), | ||
| : admin_("/dev/null", "/tmp/envoy.prof", Network::Utility::resolveUrl("tcp://127.0.0.1:9002"), |
There was a problem hiding this comment.
This isn't a fault in this PR (it's a widespread issue in Envoy today), but using /tmp is kind of dangerous, since you may conflict with other users or test runs in a shared environment. You can keep the code as is, since we don't have a better solution yet, but add a TODO(htuch): Use proper temporary path allocation method. here?
|
@hennna please sign CLA if you didn't already. |
|
@mattklein123 just signed CLA |
source/common/profiler/profiler.h
Outdated
|
|
||
| /** | ||
| * Start the profiler and write to the specified path. | ||
| * @return bool whether the call to start profiler succeeded. |
source/server/http/admin.h
Outdated
|
|
||
| Server::Instance& server_; | ||
| std::list<Http::AccessLog::InstanceSharedPtr> access_logs_; | ||
| std::string profile_path_; |
| #ifdef TCMALLOC | ||
|
|
||
| TEST_F(IntegrationTest, AdminCpuProfilerStart) { | ||
| BufferingStreamDecoderPtr response = IntegrationUtil::makeSingleRequest( |
There was a problem hiding this comment.
I don't think you meant to move this request ("/") inside here. Should go back in other section.
test/server/http/admin_test.cc
Outdated
|
|
||
| TEST_F(AdminFilterTest, AdminBadProfiler) { | ||
| Buffer::OwnedImpl data; | ||
| AdminImpl admin_bad_profile_path("/dev/null", "/var/log/envoy/envoy.prof", |
There was a problem hiding this comment.
This is not going to fail in all envs. I would use a totally bogus path here.
| {"/server_info", "print server version/status information", | ||
| MAKE_HANDLER(handlerServerInfo)}, | ||
| {"/stats", "print server stats", MAKE_HANDLER(handlerStats)}} { | ||
|
|
| EXPECT_STREQ("200", response->headers().Status()->value().c_str()); | ||
|
|
||
| response = IntegrationUtil::makeSingleRequest(ADMIN_PORT, "GET", "/hot_restart_version", "", | ||
| response = IntegrationUtil::makeSingleRequest(ADMIN_PORT, "GET", "/certs", "", |
There was a problem hiding this comment.
What's going on with all these handler path changes? They don't seem related.
There was a problem hiding this comment.
I moved the two enable=y and enable=n into it's own integration test called AdminCpuProfilerStart. I think this has to do with line order changes.
test/server/http/admin_test.cc
Outdated
|
|
||
| TEST_F(AdminFilterTest, AdminBadProfiler) { | ||
| Buffer::OwnedImpl data; | ||
| AdminImpl admin_bad_profile_path("/dev/null", "/var/log/envoy/envoy.prof", |
There was a problem hiding this comment.
/var/log/envoy/envoy.prof might be a valid path in some environments. Maybe use /some/unlikely/bad/path.prof for now, we should deal with this better when cleaning up the temp file story. Another approach would be to mock file handling, but I think this is a bit of clutter and overhead to put this dependency injection into AdminImpl.
Automatic merge from submit-queue [DO NOT MERGE] Auto PR to update dependencies of proxy This PR will be merged automatically once checks are successful. ```release-note none ```
Signed-off-by: John Plevyak <jplevyak@gmail.com>
Description: currently apps would fail in IPv6 only networks. This configuration change makes it so that the default setting is used, which is AUTO. Risk Level: low Testing: will test on device Thanks to @theatrus for reporting! Signed-off-by: Jose Nino <jnino@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
Description: currently apps would fail in IPv6 only networks. This configuration change makes it so that the default setting is used, which is AUTO. Risk Level: low Testing: will test on device Thanks to @theatrus for reporting! Signed-off-by: Jose Nino <jnino@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
Step 1
Step 2
Issue link: #596
@htuch for comments.