agent: prevent duplicate error messages for maintenance api
This commit is contained in:
parent
8081403ad9
commit
718cd94b50
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue