diff --git a/command/agent/agent_endpoint.go b/command/agent/agent_endpoint.go index 0636b01c83..d7cfeb9e7f 100644 --- a/command/agent/agent_endpoint.go +++ b/command/agent/agent_endpoint.go @@ -224,14 +224,17 @@ func (s *HTTPServer) AgentServiceMaintenance(resp http.ResponseWriter, req *http if err = s.agent.EnableServiceMaintenance(serviceID, reason); err != nil { resp.WriteHeader(404) resp.Write([]byte(err.Error())) + return nil, nil } } else { if err = s.agent.DisableServiceMaintenance(serviceID); err != nil { resp.WriteHeader(404) resp.Write([]byte(err.Error())) + return nil, nil } } - return nil, err + + return nil, nil } func (s *HTTPServer) AgentNodeMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error) { diff --git a/command/agent/agent_endpoint_test.go b/command/agent/agent_endpoint_test.go index c54f832f92..8e0fbe4f9a 100644 --- a/command/agent/agent_endpoint_test.go +++ b/command/agent/agent_endpoint_test.go @@ -542,9 +542,6 @@ func TestHTTPAgent_ServiceMaintenanceEndpoint_BadRequest(t *testing.T) { // Fails when bad service ID provided req, _ = http.NewRequest("PUT", "/v1/agent/service/maintenance/_nope_?enable=true", nil) resp = httptest.NewRecorder() - if _, err := srv.AgentServiceMaintenance(resp, req); err == nil { - t.Fatalf("should have errored") - } if resp.Code != 404 { t.Fatalf("expected 404, got %d", resp.Code) }