address pr feedback

This commit is contained in:
Drew Bailey
2019-12-16 13:42:18 -05:00
parent cd7652fed8
commit 1776458956
9 changed files with 35 additions and 34 deletions

View File

@@ -336,15 +336,15 @@ func (s *HTTPServer) AgentForceLeaveRequest(resp http.ResponseWriter, req *http.
func (s *HTTPServer) AgentPprofRequest(resp http.ResponseWriter, req *http.Request) ([]byte, error) {
path := strings.TrimPrefix(req.URL.Path, "/v1/agent/pprof/")
switch {
case path == "":
switch path {
case "":
// no root index route
return nil, CodedError(404, ErrInvalidMethod)
case path == "cmdline":
case "cmdline":
return s.agentPprof(profile.CmdReq, resp, req)
case path == "profile":
case "profile":
return s.agentPprof(profile.CPUReq, resp, req)
case path == "trace":
case "trace":
return s.agentPprof(profile.TraceReq, resp, req)
default:
// Add profile to request

View File

@@ -389,7 +389,7 @@ func TestHTTP_AgentMonitor(t *testing.T) {
})
}
// Scenerios when Pprof requests should be available
// Scenarios when Pprof requests should be available
// see https://github.com/hashicorp/nomad/issues/6496
// +---------------+------------------+--------+------------------+
// | Endpoint | `enable_debug` | ACLs | **Available?** |

View File

@@ -219,7 +219,9 @@ func (s *HTTPServer) registerHandlers(enableDebug bool) {
s.mux.Handle("/", handleRootFallthrough())
if enableDebug {
s.logger.Warn("enable_debug is set to true. This is insecure and should not be enabled in production")
if !s.agent.config.DevMode {
s.logger.Warn("enable_debug is set to true. This is insecure and should not be enabled in production")
}
s.mux.HandleFunc("/debug/pprof/", pprof.Index)
s.mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
s.mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
@@ -358,7 +360,7 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque
return f
}
// wrapNonJON is used to wrap functions returning non JSON
// wrapNonJSON is used to wrap functions returning non JSON
// serializeable data to make them more convenient. It is primarily
// responsible for setting nomad headers and logging.
func (s *HTTPServer) wrapNonJSON(handler func(resp http.ResponseWriter, req *http.Request) ([]byte, error)) func(resp http.ResponseWriter, req *http.Request) {

View File

@@ -11,12 +11,6 @@ import (
"time"
)
// goroutine
// threadcreate
// heap
// allocs
// block
// mutex
type ReqType string
const (