myxce/src/frontend/apiserver/backend
lei.chen c90e63ec0f fix(frontend): job control no longer returns HTTP 500 (bug-1490)
Two stacked defects in the apiserver job-control link, both of which kept
hold/release/cancel from ever reaching the controller:

1. controllers/jobs.go: validateJobControl and foundJob asserted
   jobinfo.Data["array_idx"].(int64), but StoreToOrderMaps produces
   array_idx as int (models.JobInfo.ArrayIdx is declared int) -> panic
   -> Gin Recovery -> HTTP 500 before backend.ControlJob ran. Add
   normalizeJobInt64 / jobArrayIdx helpers and use them in both
   functions (job_status already had this fix via normalizeJobStatus;
   array_idx was missed).

2. backend/clib.go: backend.ControlJob set xce_jobctrl_t.action to the
   models.JOB_* constant (JOB_STOP=1 / JOB_RESUME=2 / JOB_KILL=3 /
   JOB_CHKPNT=8), but that field is the capnp JobControl union
   discriminant (JobControl_u_siginfo=0 / JobControl_u_ckptoption=1).
   The controller's job_ctrl() selected the wrong union branch (or
   none, since encode_JobControl drops the union pointer for
   non-0/1 discriminants) and rejected every control with -EINVAL.
   Add jobCtrlDiscriminant() and use it.

Also: resolveExecUser was defined in the cgo-only convert.go but is
exercised by a non-cgo test, so `make test` (CGO_ENABLED=0) failed to
build the backend package. Move it to convert_pure.go so it compiles in
both modes.

Tests: 3 controller regression tests (validateJobControl allowed /
not-allowed branches, foundJob array-child branch) + 1 backend
jobCtrlDiscriminant test. make test fully green. Cluster E2E verified:
hold -> PSUSP, release -> PEND, cancel -> EXIT on a PEND job, no 500,
no -EINVAL, all daemons healthy.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-07 07:35:51 +00:00
..
auth Merge Go frontend (apiserver + xcecli) into meson build 2026-04-14 11:23:18 +08:00
clib.go fix(frontend): job control no longer returns HTTP 500 (bug-1490) 2026-08-07 07:35:51 +00:00
config.go Merge branch 'working' into job_peek_lchen 2026-07-22 13:57:25 +08:00
control_host_test.go fix: address P0-2b review issues - build tag and actionType guard 2026-04-17 08:25:05 +00:00
convert.go fix(frontend): job control no longer returns HTTP 500 (bug-1490) 2026-08-07 07:35:51 +00:00
convert_pure.go fix(frontend): job control no longer returns HTTP 500 (bug-1490) 2026-08-07 07:35:51 +00:00
convert_test.go fix(frontend): job control no longer returns HTTP 500 (bug-1490) 2026-08-07 07:35:51 +00:00
handler.go fix(schema): rename struct Data -> XceData to unshadow capnp builtin blob type 2026-07-22 09:22:04 +00:00
handler_test.go fix(schema): rename struct Data -> XceData to unshadow capnp builtin blob type 2026-07-22 09:22:04 +00:00
heartbeat.go fix: P1-3 address heartbeat timer leak, test drain, and store consistency 2026-04-17 14:20:02 +00:00
heartbeat_test.go fix: P1-3 address heartbeat timer leak, test drain, and store consistency 2026-04-17 14:20:02 +00:00
integration_test.go fix front end issues 2026-05-01 21:22:45 +08:00
notification.go fix front end issues 2026-05-01 21:22:45 +08:00
peers.go refactor: simplify HA backend peer handling 2026-05-08 03:41:11 +00:00
peers_test.go feat: add HA candidate failover to API server backend 2026-05-08 03:31:35 +00:00
stub.go Init commit of jobs output/error message peek project. 2026-05-09 16:57:54 +08:00
stub_funcs_test.go feat: add HA candidate failover to API server backend 2026-05-08 03:31:35 +00:00
val_helpers.h test(apiserver): add integration tests for P0+P1 backend features 2026-04-18 11:56:31 +00:00
wire_dispatch_support.go fix(schema): rename struct Data -> XceData to unshadow capnp builtin blob type 2026-07-22 09:22:04 +00:00
wire_dispatch_test.go test(job-array-single-wal-record): end-to-end integration test for the compact push 2026-07-15 17:27:34 +00:00