fix: scheduler empty-resreq JOB_UPDATE crash (bug-1904); xcecli jobs list rejection text (bug-1906)

bug-1904: both scheduler JOB_UPDATE paths parsed "" as-is:
parse_resreq() returns success with a PRIMARY container whose body is
NULL, and apply_job_task_count() wrote through it. Use ingest's default
("type == any") instead.

bug-1906: xcecli jobs list sent local selection-parse errors through
ExtractErrorMessage, which strips brackets and the quoted selection;
report them as written.

Also logs bug-1905 (xcecd_virtual ignores kill of a running job). All
three found by job-array-one-based-index task 10.2's live REST flow.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-10-01 14:34:17 +00:00
parent 6439e5852f
commit 6e631caa22
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
9 changed files with 392 additions and 12 deletions

View file

@ -199,6 +199,7 @@ extern int scheduler_req_handler(xce_request_t*, void*);
* design.md's "Project Invariant Cross-Check" commitment, now lives in its
* own separate file, test_maxtasks_wiring_sim_driver_parity.c.) */
#define JOBID_UPDATE_IMMUNE ((uint64_t)910501ULL)
#define JOBID_UPDATE_EMPTY ((uint64_t)910502ULL)
#define JOBID_CACHE_A ((uint64_t)910601ULL)
#define JOBID_CACHE_B ((uint64_t)910602ULL)
@ -1166,6 +1167,67 @@ test_differing_task_counts_do_not_collide_in_unsatisfiable_cache(void)
TEST_ASSERT_EQUAL_INT(7, out_reason);
}
/*
* bug-1904: a JOB_UPDATE whose resreq is the empty string (a REST job
* submitted without -R) parsed "" as-is: parse_resreq() succeeds on it
* with a zeroed PRIMARY container whose u.primary is NULL, and
* apply_job_task_count() then wrote through NULL, killing the scheduler.
* The update must treat "" as ingest does ("type == any").
*/
static void test_job_update_with_empty_resreq_uses_default(void)
{
xce_sched_core_t core;
xce_queue_t* queue;
xce_core_event_t queue_event;
xce_job_t* job_ptrs[1];
xce_core_event_t job_event;
xce_job_t* update_job;
xce_core_event_t update_event;
xce_sched_job_t* sjob;
int rc;
rc = xce_sched_core_init(&core);
TEST_ASSERT_TRUE(rc >= 0);
queue = make_wire_queue("normal", 1);
memset(&queue_event, 0, sizeof(queue_event));
queue_event.type = XCE_CORE_EVENT_QUEUE_UPDATE;
queue_event.u.queue_update.queue = queue;
TEST_ASSERT_TRUE(xce_core_push_events(&core, &queue_event, 1) >= 0);
job_ptrs[0] = make_push_job(JOBID_UPDATE_EMPTY, "", "alice", "normal",
"proj1", 2, 3);
memset(&job_event, 0, sizeof(job_event));
job_event.type = XCE_CORE_EVENT_JOBS_PUSH;
job_event.u.jobs_push.njobs = 1;
job_event.u.jobs_push.jobs = job_ptrs;
TEST_ASSERT_TRUE(xce_core_push_events(&core, &job_event, 1) >= 0);
update_job = make_push_job(JOBID_UPDATE_EMPTY, "", "alice", "normal",
"proj1", 2, 3);
memset(&update_event, 0, sizeof(update_event));
update_event.type = XCE_CORE_EVENT_JOB_UPDATE;
update_event.u.job_update.jobid = JOBID_UPDATE_EMPTY;
update_event.u.job_update.job = update_job;
rc = xce_core_push_events(&core, &update_event, 1);
TEST_ASSERT_TRUE_MESSAGE(rc >= 0, "JOB_UPDATE with an empty resreq must "
"succeed");
sjob = sched_get_job(&core, JOBID_UPDATE_EMPTY);
TEST_ASSERT_NOT_NULL(sjob);
TEST_ASSERT_NOT_NULL(sjob->resreq);
TEST_ASSERT_EQUAL_INT(XCE_RESREQ_PRIMARY, sjob->resreq->tag);
TEST_ASSERT_NOT_NULL_MESSAGE(sjob->resreq->u.primary,
"bug-1904: an empty resreq update must "
"parse as the default request");
TEST_ASSERT_EQUAL_STRING("type == any", sjob->resreq_str);
TEST_ASSERT_EQUAL_INT(2, sjob->resreq->u.primary->minTasks);
TEST_ASSERT_EQUAL_INT(3, sjob->resreq->u.primary->maxTasks);
TEST_ASSERT_NOT_NULL(sjob->schedobj);
TEST_ASSERT_TRUE(sjob->schedobj->u.primary->resreq
== sjob->resreq->u.primary);
}
int main(void)
{
UNITY_BEGIN();
@ -1175,6 +1237,7 @@ int main(void)
RUN_TEST(
test_single_task_job_dispatch_and_host_selection_unchanged_via_real_allocator);
RUN_TEST(test_resource_request_update_never_changes_dispatched_task_count);
RUN_TEST(test_job_update_with_empty_resreq_uses_default);
RUN_TEST(test_differing_task_counts_do_not_collide_in_unsatisfiable_cache);
return UNITY_END();
}