Pre-existing uncommitted work: ha-repl-hardening payload data plane (7.x), heartbeat liveness fix (Req 1.3), connection-reuse ASAN fixes, doc cleanup. New: ha-consistency-invariants umbrella (requirements/design/research) and its four implementation sub-specs (specs generated via batch, cross-spec review applied), steering roadmap + product.md Raft+CP decision.
9.2 KiB
Tasks: scheduler-controller-msg-gap
Generated: 2026-05-11T19:30:00-07:00 Feature: scheduler-controller-msg-gap Status: Tasks Generated
Overview
Implementation tasks for filling gaps in the scheduler's handling of controller messages. The work follows the design's build order: shared helpers first, then header definitions, plugin hooks, business logic, handler wiring, and finally tests.
Task 1: Add name-lookup helpers to lib/helper
Requirements: 8
Add xce_notify_event_name() and xce_sched_op_name() to src/lib/helper.c and declare them in src/include/helper.h, following the exact pattern of the existing xce_dataset_table() helper (int argument, char* return, "UNKNOWN(%d)" fallback).
- 1.1 Declare
xce_notify_event_name(int event)andxce_sched_op_name(xce_sched_op_t op)insrc/include/helper.h - 1.2 Implement
xce_notify_event_name()insrc/lib/helper.c— switch on allNotifyData_data_*enum values; return symbolic string; fall back to"UNKNOWN(%d)" - 1.3 Implement
xce_sched_op_name()insrc/lib/helper.c— switch on allXCE_SCHED_OP_*enum values; return symbolic string; fall back to"UNKNOWN(%d)"
Task 2: Extend scheduler.h with new op types and request fields
Requirements: 1, 3, 4, 5, 6
Add five new xce_sched_op_t enum values and five corresponding union members in xce_sched_update_request_t to carry the payloads for queue update, resource update, full resval update, incremental resval update, and job rusage.
- 2.1 Add
XCE_SCHED_OP_UPDATE_QUEUE,XCE_SCHED_OP_UPDATE_RESOURCES,XCE_SCHED_OP_UPDATE_RESVALS_FULL,XCE_SCHED_OP_UPDATE_RESVALS, andXCE_SCHED_OP_JOB_RUSAGEto thexce_sched_op_tenum insrc/scheduler/include/scheduler.h - 2.2 Add the corresponding named union members (
queueupdate,resourceupdate,resvalfullupdate,resvalupdate,job_rusage) toxce_sched_update_request_t
Task 3: Add plugin rusage hook
Requirements: 6
Add the plugin_job_rusage_hook_t typedef, the rusage_hook field in plugin_hooks_t, and the plugin_job_rusage_update() global function. This follows the identical pattern used by plugin_job_state_change().
- 3.1 Add
plugin_job_rusage_hook_ttypedef andrusage_hookfield toplugin_hooks_tinsrc/scheduler/include/plugin.h - 3.2 Implement
plugin_job_rusage_update()insrc/scheduler/src/plugin.c— iterate registered plugins and call theirrusage_hookwhen non-NULL
Task 4: Add queue update function in schedobj.c
Requirements: 4
Implement sched_update_existing_queue() in src/scheduler/src/schedobj.c. The function locates a queue by name via sched_get_queue(), updates its mutable fields (status, priority, accept_interval, sched_delay, resreq string), calls plugin_queue_update(), and returns -ENOENT if the queue is unknown.
- 4.1 Implement
sched_update_existing_queue(xce_scheduler_t*, xce_queue_t*)insrc/scheduler/src/schedobj.cwith correct lookup, field update, string reallocation for resreq, plugin call, and error returns
Task 5: Extend scheduler.c dequeue processing and error logging
Requirements: 1, 3, 4, 5, 6, 7
Wire the five new op types into the switch (req->op) in sched_update(), implement sched_update_existing_job(), and add WARN-level error logging after the switch when a handler returns non-zero.
- 5.1 Add
XCE_SCHED_OP_UPDATE_QUEUEcase — delegate tosched_update_existing_queue(), return-ENOENTwhen queue not found - 5.2 Add
XCE_SCHED_OP_UPDATE_RESOURCEScase — iterateresdata->resources[], callmakeResource(sched->resmgr, r)for each non-NULL entry - 5.3 Add
XCE_SCHED_OP_UPDATE_RESVALS_FULLcase — iterateresvaldata->vals[], find resource insched->resmgrby name, update value; log WARN and skip unknown resources - 5.4 Add
XCE_SCHED_OP_UPDATE_RESVALScase — iterateresvals->vals[], find worker by host name viasched_get_worker(), update worker'sresvalszarray; silently skip unknown hosts - 5.5 Add
XCE_SCHED_OP_JOB_RUSAGEcase — find job by jobid, store rusage data, callplugin_job_rusage_update(); return-ENOENTif job not found - 5.6 Implement
sched_update_existing_job()— find job by jobid viasched_get_job(), update mutable fields (state, priority, allocs), callplugin_job_update(); return-ENOENTwhen jobid is unknown - 5.7 Add WARN log in
sched_update()after switch block for non-zerorc— include symbolic op name viaxce_sched_op_name()andstrerror(-rc) - 5.8 Extend
sched_pend_update_killerwith no-op cases for all five new op types to suppress unhandled-case compiler warnings
Task 6: Wire notify handlers in handler.c
Requirements: 3, 4, 5, 6, 8
Add four static handler functions for the currently-stubbed NotifyData events, wire them into sched_handle_notify(), and update the TRACE log calls in sched_handle_notify() and sched_handle_dataset() to use symbolic name helpers.
- 6.1 Implement
sched_handle_sched_update_job()— validate non-NULL, enqueueXCE_SCHED_OP_UPDATE_JOB; return-EINVALon NULL,-ENOMEMon alloc failure - 6.2 Implement
sched_handle_sched_update_queue()— validate non-NULL, enqueueXCE_SCHED_OP_UPDATE_QUEUE; return-EINVALon NULL,-ENOMEMon alloc failure - 6.3 Implement
sched_handle_sched_update_resvals()— skip if NULL or count==0, enqueueXCE_SCHED_OP_UPDATE_RESVALS; return-ENOMEMon alloc failure - 6.4 Implement
sched_handle_sched_job_rusage()— validate non-NULL, enqueueXCE_SCHED_OP_JOB_RUSAGE; return-EINVALon NULL,-ENOMEMon alloc failure - 6.5 Wire all four handlers into
sched_handle_notify()switch — replace stubbreak/ TRACE-only cases - 6.6 Update TRACE log in
sched_handle_dataset()from%dtable integer to%sviaxce_dataset_table()(8.2), and update notify event logs to usexce_notify_event_name()(8.3)
Task 7: Add dataset handlers in handler.c
Requirements: 1, 8
Add sched_handle_resources() and sched_handle_resvals() static functions and wire them into the sched_handle_dataset() switch for the two currently-empty Data table cases. Update the existing opcode log in scheduler_req_handler to use xce_request_op_name().
- 7.1 Implement
sched_handle_resources()— skip if NULL or count==0, enqueueXCE_SCHED_OP_UPDATE_RESOURCES; return-ENOMEMon alloc failure - 7.2 Implement
sched_handle_resvals()— skip if NULL or count==0, enqueueXCE_SCHED_OP_UPDATE_RESVALS_FULL; return-ENOMEMon alloc failure - 7.3 Wire
sched_handle_resources()andsched_handle_resvals()intosched_handle_dataset()switch replacing the emptybreakcases - 7.4 Update opcode log in
scheduler_req_handlerto callxce_request_op_name()instead of printing the numeric value (8.1)
Task 8: Remove dead code pushmsg branches
Requirements: 2
Delete the Request_body_pushmsg case block from scheduler_req_handler() and the static functions sched_handle_jobpush() and sched_handle_workerpush(). These paths are unreachable because vtask_entry() rewrites all pushmsg into datamsg before invoking the handler.
- 8.1 Remove the
Request_body_pushmsgcase and its two nested branches (job/worker) fromscheduler_req_handler()insrc/scheduler/src/handler.c - 8.2 Remove the static function definitions
sched_handle_jobpush()andsched_handle_workerpush()fromsrc/scheduler/src/handler.c
Task 9: Write unit tests for all new message handlers
Requirements: 1, 2, 3, 4, 5, 6, 7, 8
Extend src/scheduler/testsuite/test.c with unit tests covering every acceptance criterion. Tests must run without a live server — use stub schedulers, table-driven cases, and the existing testsuite harness.
- 9.1 Test
xce_notify_event_name()andxce_sched_op_name()— verify known values return correct strings, unknown values return"UNKNOWN(%d)"format - 9.2 Test
sched_handle_resources()andsched_handle_resvals()handler functions — verify enqueue on valid input, skip on NULL/empty,-ENOMEMpath - 9.3 Test
sched_handle_sched_update_job(),sched_handle_sched_update_queue(),sched_handle_sched_update_resvals(),sched_handle_sched_job_rusage()— verify-EINVALon NULL, enqueue on valid input - 9.4 Test
sched_update_existing_job()— verify-ENOENTfor unknown jobid, correct field update and plugin call for known jobid - 9.5 Test
sched_update_existing_queue()— verify-ENOENTfor unknown queue, correct field update and plugin call for known queue; verify-EINVALon NULL payload - 9.6 Test dequeue path for
XCE_SCHED_OP_UPDATE_RESVALS— verify unknown host skipped, known host updated - 9.7 Test dequeue path for
XCE_SCHED_OP_JOB_RUSAGE— verify-ENOENTfor unknown jobid, rusage stored and plugin called for known jobid; verify-EINVALon NULL rusage - 9.8 Verify dead code symbols are absent — compile-time check that
sched_handle_jobpush/sched_handle_workerpushare not defined (2.1, 2.2) - [~] 9.9 (gated: log capture infrastructure) Verify WARN log is emitted in
sched_update()when any handler returns a non-zero error code (optional — may require log capture infrastructure)