feat(scheduler-sim-live-allocation): close host-scoped limit fan-out seam gap (task 4.3)
Fully closes bug-1829's own tracked follow-up from task 4.1: retypes seqjob_allocator.c/parjob_allocator.c's init_fn AND runtime hooks (prepare_allocation_hook, job_alloc_fn) to read the plugin's own honest plugin->core field (task 1.2) instead of deriving an xce_scheduler_t* from plugin->sched -- mirroring task 2.3's limit.c migration exactly. The gap was broader than initially scoped: not just init_fn, but every runtime hook independently derived sched from plugin->sched on each allocation attempt. Adds seqjob_allocator_new_plugin()/parjob_allocator_new_plugin() factories (plugin.h, mirroring limit_new_plugin()), letting sim_alloc.c's bootstrap functions register both plugins DIRECTLY against &(sim->core) via the existing plugin_register_core() -- the same call sim_bootstrap_picker()/sim_bootstrap_limit_plugin() already use. Task 4.1's throwaway xce_scheduler_t wrapper is gone from the plugin-registry/fan-out path entirely; plugin_prepare_allocation()'s fan-out during a live seqjob/parjob dispatch now genuinely reaches sim->core.plugins, the same registry the limit plugin is registered in. One narrow, necessary exception remains, independently verified confined: my_alloc() still needs a small xce_scheduler_t wrapper (only .core.resmgr aliased to sim->core) to satisfy sched_make_allocs() (scheduler.c, out of this task's boundary, unmodified) -- set on plugin->sched only AFTER plugin_register_core() has run, never read by the plugin registry or any prepare_allocation_hook fan-out. TDD: new test_sim_alloc_limit_fanout.c drives a real live dispatch (sched_job_picker()/sched_allocator() thread pair) with a host-scoped limit registered directly against sim->core, proving a real usage instance is created -- isolated from both reconciliation and global-limit matching. RED: dispatch succeeded but the usage-instance iterator was empty. GREEN: 82/82, zero regressions. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
parent
915782fc66
commit
f6a2862110
12 changed files with 778 additions and 193 deletions
|
|
@ -95,6 +95,12 @@ int plugin_prepare_allocation(xce_sched_core_t* sched, xce_sched_ctx_t* ctx)
|
|||
|
||||
memset(&fake_plugin, 0, sizeof(fake_plugin));
|
||||
fake_plugin.sched = sched;
|
||||
/* scheduler-sim-live-allocation spec, task 4.3: seqjob_prepare_
|
||||
* allocation() now reads plugin->core (honestly typed, task 1.2)
|
||||
* instead of plugin->sched -- `sched` here is already an
|
||||
* xce_sched_core_t* (this stub's own signature), so no cast is
|
||||
* needed. */
|
||||
fake_plugin.core = sched;
|
||||
|
||||
return seqjob_prepare_allocation(&fake_plugin, ctx);
|
||||
}
|
||||
|
|
@ -280,6 +286,11 @@ test_my_alloc_allocates_single_matching_host_through_shared_iterators(void)
|
|||
|
||||
memset(&plugin, 0, sizeof(plugin));
|
||||
plugin.sched = &sched;
|
||||
/* scheduler-sim-live-allocation spec, task 4.3: my_alloc() now reads
|
||||
* plugin->core (honestly typed, task 1.2) for every core-safe call,
|
||||
* alongside the still-needed plugin->sched (sched_make_allocs(),
|
||||
* scheduler.c, unchanged). */
|
||||
plugin.core = &(sched.core);
|
||||
|
||||
rc = my_alloc(&plugin, &ctx);
|
||||
|
||||
|
|
@ -341,6 +352,9 @@ test_seqjob_prepare_allocation_guards_against_maxtasks_gt_1_fanout(void)
|
|||
|
||||
memset(&plugin, 0, sizeof(plugin));
|
||||
plugin.sched = &sched;
|
||||
/* scheduler-sim-live-allocation spec, task 4.3: seqjob_prepare_
|
||||
* allocation() now reads plugin->core (honestly typed, task 1.2). */
|
||||
plugin.core = &(sched.core);
|
||||
|
||||
ctx.worker = NULL;
|
||||
rc = seqjob_prepare_allocation(&plugin, &ctx);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue