fix(apiserver): answer the controller's queue rejections as client errors (bug-1960)
Since the controller rejects submissions to closed or unknown queues (E_XCE_QUEUE_CLOSED, E_XCE_BAD_QUEUE), the apiserver answered them as a 500 "xcecli_jobsubmit failed: -10016". SubmitJob now maps them to backend.ErrQueueClosed / ErrQueueInvalid (numbers checked against errnox.h at compile time), and the submit and restart handlers answer 400 naming the queue, as the apiserver's own pre-check does. This covers a queue closed between that check and the controller's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b239db5fa3
commit
4f57904134
5 changed files with 111 additions and 1 deletions
|
|
@ -1577,3 +1577,29 @@ func TestJobHandler_SubmitRejectsNonObjectExtendData(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bug-1960: a submission the controller rejects for its queue (closed after
|
||||
// the apiserver's own check, or unknown) is a client error naming the queue,
|
||||
// not a 500 with a raw error number.
|
||||
func TestJobHandler_SubmitQueueRejectedByController(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
err error
|
||||
want string
|
||||
}{
|
||||
{backend.ErrQueueClosed, "queue is closed"},
|
||||
{backend.ErrQueueInvalid, "invalid queue"},
|
||||
} {
|
||||
f := newHandlerFixture(t)
|
||||
f.seedQueue("normal")
|
||||
f.submitErr = tc.err
|
||||
w := f.submit(map[string]interface{}{"command": "sleep 1", "queue_name": "normal"})
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Errorf("%v: status = %d, want 400; body: %s", tc.err, w.Code, w.Body.String())
|
||||
continue
|
||||
}
|
||||
msg, _ := decodeHandlerResponse(t, w).Msg.(string)
|
||||
if !strings.Contains(msg, tc.want) || !strings.Contains(msg, "normal") {
|
||||
t.Errorf("%v: msg = %q, want it to name the queue and say %q", tc.err, msg, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue