refactor(scheduler): one schedobj builder for ingest and snapshot restore (bug-1767)

snapshot_load.c carried its own field-for-field copy of core_events.c's
schedobj builders (primary/compound/alter + hlimits killer), kept separate
by a "never share builders" convention. The copy drifted from the original
three times, each a field-completeness bug in restored jobs (bug-1772's
all-zero resreq_fp among them). The convention's reasons apply to the
job/queue/worker builders, not to schedobj, which is never wire-captured.

- core_build_schedobj() becomes the exported xce_core_build_schedobj(obj,
  user, queue, project, resreq) (core.h), taking identity strings instead
  of a wire job; core_build_job() and snapshot_load.c both call it.
- snapshot_load.c's five copied functions are removed.
- test_sim_startup.c #includes snapshot_load.c without core_events.c; it
  now also #includes core_events.c, plus the same
  sched_reconcile_job_resource_usage link stub test_driver_translate.c
  uses.
- test_fresh_ingest_and_snapshot_restore_derive_identical_... now compares
  the whole schedobj (tag, user/queue/project, configver, glimits, owner,
  resreq binding, resreq_fp), guarding against future drift. No RED phase:
  there is no live gap left to catch; this removes the duplication that
  kept producing them.

Scheduler suite 87/87; full build links.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-09-27 03:14:53 +00:00
parent 6103150084
commit 1dfdf42cc9
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
5 changed files with 70 additions and 158 deletions

View file

@ -434,6 +434,16 @@ extern int sched_charge_account(xce_sched_core_t*, xce_job_account_t*);
extern int sched_uncharge_account(xce_sched_core_t*, xce_job_account_t*);
extern int sched_commit_job_alloc(xce_sched_core_t*, xce_sched_job_t*);
/*
* xce_core_build_schedobj() - fill a calloc'd xce_sched_obj_t for a job with
* the given identity and parsed resreq (defined in core_events.c). The only
* schedobj builder: fresh ingest and snapshot restore (snapshot_load.c) both
* call it, so they cannot drift apart (bug-1767).
*/
extern void xce_core_build_schedobj(xce_sched_obj_t*, const char* user,
const char* queue, const char* project,
xce_resreq_t*);
/*
* sched_check_host_satisfy()/sched_check_shared_satisfy() - relocated here
* from scheduler.h (scheduler-driver-equivalence fix, bug-1836), following