Merge pull request #2339 from hashicorp/b-job-delete
Deregistering non-existant job returns 404
This commit is contained in:
commit
084b63e711
|
@ -327,7 +327,11 @@ func (s *HTTPServer) jobDelete(resp http.ResponseWriter, req *http.Request,
|
|||
s.parseRegion(req, &args.Region)
|
||||
|
||||
var out structs.JobDeregisterResponse
|
||||
if err := s.agent.RPC("Job.Deregister", &args, &out); err != nil {
|
||||
err := s.agent.RPC("Job.Deregister", &args, &out)
|
||||
if err != nil {
|
||||
if strings.HasSuffix(err.Error(), "does not exist") {
|
||||
return nil, CodedError(404, err.Error())
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
setIndex(resp, out.Index)
|
||||
|
|
|
@ -389,6 +389,10 @@ func (j *Job) Deregister(args *structs.JobDeregisterRequest, reply *structs.JobD
|
|||
return err
|
||||
}
|
||||
|
||||
if job == nil {
|
||||
return fmt.Errorf("job %q does not exist", args.JobID)
|
||||
}
|
||||
|
||||
// Commit this update via Raft
|
||||
_, index, err := j.srv.raftApply(structs.JobDeregisterRequestType, args)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue