diff --git a/command/agent/agent_endpoint.go b/command/agent/agent_endpoint.go index d5fe6a0df..044eadb16 100644 --- a/command/agent/agent_endpoint.go +++ b/command/agent/agent_endpoint.go @@ -192,13 +192,12 @@ func (s *HTTPServer) AgentMonitor(resp http.ResponseWriter, req *http.Request) ( } s.parse(resp, req, &args.QueryOptions.Region, &args.QueryOptions) - // Determine the handler to use - useLocalClient, useClientRPC, useServerRPC := s.rpcHandlerForNode(nodeID) - // Make the RPC var handler structs.StreamingRpcHandler var handlerErr error if nodeID != "" { + // Determine the handler to use + useLocalClient, useClientRPC, useServerRPC := s.rpcHandlerForNode(nodeID) if useLocalClient { handler, handlerErr = s.agent.Client().StreamingRpcHandler("Agent.Monitor") } else if useClientRPC { @@ -229,10 +228,10 @@ func (s *HTTPServer) AgentMonitor(resp http.ResponseWriter, req *http.Request) ( // Create an ouput that gets flushed on every write output := ioutils.NewWriteFlusher(resp) - // Create a channel that decodes the results + // create an error channel to handle errors errCh := make(chan HTTPCodedError, 2) - // stream the response + // stream response go func() { defer cancel() diff --git a/command/agent/agent_endpoint_test.go b/command/agent/agent_endpoint_test.go index 9c4cadb5e..0a4cb1f01 100644 --- a/command/agent/agent_endpoint_test.go +++ b/command/agent/agent_endpoint_test.go @@ -279,8 +279,7 @@ func TestHTTP_AgentMonitor(t *testing.T) { require.NoError(t, err) }() - // send the same log a few times until monitor sink is - // fully set up + // send the same log until monitor sink is set up maxLogAttempts := 10 tried := 0 testutil.WaitForResult(func() (bool, error) { @@ -315,8 +314,7 @@ func TestHTTP_AgentMonitor(t *testing.T) { require.NoError(t, err) }() - // send the same log a few times until monitor sink is - // fully set up + // send the same log until monitor sink is set up maxLogAttempts := 10 tried := 0 out := "" @@ -370,7 +368,6 @@ func TestHTTP_AgentForceLeave(t *testing.T) { httpTest(t, nil, func(s *TestAgent) { // Make the HTTP request req, err := http.NewRequest("PUT", "/v1/agent/force-leave?node=foo", nil) - require.Nil(t, err) if err != nil { t.Fatalf("err: %v", err) } diff --git a/command/agent/command.go b/command/agent/command.go index c0567bda8..da3e40e90 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -382,7 +382,6 @@ func (c *Command) setupLoggers(config *Config) (*gatedwriter.Writer, io.Writer) Writer: &cli.UiWriter{Ui: c.Ui}, } - // TODO can this be killed c.logFilter = LevelFilter() c.logFilter.MinLevel = logutils.LogLevel(strings.ToUpper(config.LogLevel)) c.logFilter.Writer = logGate diff --git a/command/agent/testagent.go b/command/agent/testagent.go index 1dc2e0d82..a36a46116 100644 --- a/command/agent/testagent.go +++ b/command/agent/testagent.go @@ -206,7 +206,7 @@ RETRY: func (a *TestAgent) start() (*Agent, error) { if a.LogOutput == nil { - a.LogOutput = io.MultiWriter(testlog.NewWriter(a.T)) + a.LogOutput = testlog.NewWriter(a.T) } inm := metrics.NewInmemSink(10*time.Second, time.Minute) diff --git a/command/agent_monitor.go b/command/agent_monitor.go index daeb35040..19e13abcb 100644 --- a/command/agent_monitor.go +++ b/command/agent_monitor.go @@ -28,7 +28,19 @@ Usage: nomad monitor [options] General Options: - ` + generalOptionsUsage() + ` + generalOptionsUsage() + ` + +Monitor Specific Options: + + -log-level + Sets the log level to monitor (default: INFO) + + -node-id + Sets the specific node to monitor + + -log-json + Sets log output to JSON format + ` return strings.TrimSpace(helpText) }