merge-fix: port our scheduler/worker/apiserver fixes onto scheduler-framework merge

After merging origin/scheduler-framework (scheduler-core), re-apply and
reconcile our fixes that Rongsong's branch lacked or implemented differently:

- handler.c: keep the code<0 dispatch-fail check (bug-1512: a code-0
  success ack must NOT re-PEND, or dispatched jobs spawn duplicates).
  Use sched_job_state_change (Rongsong's enqueue mechanism) instead of
  sched_requeue_pend_job so the merged test framework (pop_jstate_change)
  stays valid. Drop Rongsong's duplicate unconditional re-PEND case.
- scheduler.c: port sched_requeue_pend_job (bug-1494 class) adapted to
  sched_get_job(&sched->core, ...) signature.
- types.h: re-add xce_sched_queue_t.dispatchwindow (our time-window PEND
  reason field) dropped when taking Rongsong's types.h.
- models/jobs.go: re-add JobSubmitResponse.JobIDHuman (human job id).
- worker controller_connector.c: our bug-1509 resend_job_status on rejoin
  success was already ported; add test stub.
- tests: adapt dispatch-fail test (code=0 → no re-PEND); fix sched_get_job
  signature in white-box stubs.

Build passes (nix build .#xce). Unit + live-cluster verification pending.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
lei.chen 2026-08-25 12:53:20 +00:00
parent 4e894d2184
commit 7ea117dafa
9 changed files with 65 additions and 29 deletions

View file

@ -251,18 +251,18 @@ static void test_handle_notify_job_dispatch_fail_enqueues_pend(void)
TEST_ASSERT_EQUAL_UINT64(99, jobid);
TEST_ASSERT_EQUAL_INT(JOB_STAT_PEND, state);
/* No classification logic here: the notify's meaning is exclusively
* "return this job to pending" regardless of the reported failure
* code -- verify a different `code` value still resolves to PEND. */
/* A code of 0 is the controller's SUCCESS ack (the job was dispatched
* and is already RUN, committed at dispatch) — it must NOT be returned
* to PEND (bug-1512: re-PENDing the success ack re-elects and
* re-dispatches a job whose original instance keeps running, spawning
* duplicate instances). The ack is consumed as a no-op. */
fixture_init(&sched);
info.jobid = 123;
info.code = 0;
jobid = 0;
state = (uint32_t)-1;
TEST_ASSERT_EQUAL_INT(0, sched_handle_notify(&sched, &notify));
TEST_ASSERT_EQUAL_INT(1, pop_jstate_change(&sched, &jobid, &state));
TEST_ASSERT_EQUAL_UINT64(123, jobid);
TEST_ASSERT_EQUAL_INT(JOB_STAT_PEND, state);
TEST_ASSERT_EQUAL_INT(0, pop_jstate_change(&sched, &jobid, &state));
}
int main(int argc, char* argv[])