feat(scheduler-sim-live-allocation): make limit matching core-safe (task 2.3)
Migrates match_job_global_limit_()/limit_job_election()/ match_job_host_limit_() (plugins/limit.c) to read plugin->core (added task 1.2) instead of deriving xce_scheduler_t* from plugin->sched, which stays NULL for a plugin registered via plugin_register_core() (simulation mode). Removes the dead ctx.sched write flagged during task 2.1's review -- verified this ctx never has .sched read anywhere downstream. Fixes bug-1828 (found while writing this task's own TDD test for a previously untested code path): match_job_host_limit_() had the same key_find()-negative-rc-treated-as-fatal defect bug-1786 already fixed in its global-limit sibling, but never applied here -- meaning host-scoped resource limits were never actually enforced, in any mode, until this fix (not merely a display gap; the limit's vres was never added to obj->hlimits, so sched_fill_limit_requests() always saw an empty list for it). TDD: new tests drive the real hook-registered entry points against a plugin_register_core()-registered plugin, asserting real usage instances via limit_get_usage_instances() for both global and host-scoped limits. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
parent
ecdea8bf55
commit
fc23ea8d31
4 changed files with 347 additions and 27 deletions
|
|
@ -45,7 +45,7 @@
|
|||
- _Requirements: 1.1, 1.3, 3.1, 3.2, 5.2_
|
||||
- _Boundary: Core-Safe Allocation Chain, Unsatisfiable-Cache Callback Seam_
|
||||
|
||||
- [ ] 2.3 (P) Make global and host-scoped resource-limit matching driver-agnostic
|
||||
- [x] 2.3 (P) Make global and host-scoped resource-limit matching driver-agnostic
|
||||
- Change the limit plugin's global-limit and host-scoped-limit matching functions to read the new honest core-state reference from 1.2 instead of deriving anything from the plugin's normal-mode-only field
|
||||
- Also address the confirmed-dead, type-confused write at plugins/limit.c:319 (`ctx.sched = plugin->sched;`, flagged during task 2.1's review — never read back today, but stores an `xce_scheduler_t*`-shaped value into a field that is now genuinely `xce_sched_core_t*`-typed): either populate it honestly from the plugin's new core-state reference, or remove the dead write entirely if nothing in the migrated code path needs it
|
||||
- Keep the existing plugin-hook-registered entry points' external signature unchanged; have them resolve core state from the new field and delegate to the now-driver-agnostic matching logic
|
||||
|
|
@ -115,5 +115,6 @@
|
|||
## Implementation Notes
|
||||
|
||||
- **Task 1.1**: initial submission implemented before tests were written (TDD-mandate violation, caught in review round 1) — the real RED phase must be captured by reverting production files to HEAD via a saved patch + `git checkout --`, rebuilding to see the genuine failure, then reapplying. Retroactively-written tests plus a passing GREEN build alone do not satisfy this project's TDD discipline; the reviewer independently re-derives RED by reverting your changes, so skipping this is always caught.
|
||||
- **Task 2.3**: while migrating a plugin's matching functions, writing the mandated TDD test for a code path that had genuinely never been exercised before (zero prior test call sites for `match_job_host_limit_()`/`limit_prepare_allocation()`) surfaced a real pre-existing bug (bug-1828) blocking that path entirely — the same defect class as bug-1786, fixed the same way, never applied to this sibling function. Fixing a blocking, in-boundary, minimally-scoped pre-existing bug discovered this way is acceptable within a task rather than escalating, but its buglog entry must state the REAL impact (here: host-scoped limits were never enforced in any mode, not merely a display gap) rather than the narrower symptom that surfaced it — the first-written impact description undersold this until review caught it.
|
||||
- **Task 1.3**: grep for ALL call sites of a function before migrating it, not just the ones named in the task brief — `host_iter.c`'s `sched_host_iter_next()` and `parjob_allocator.c`/`seqjob_allocator.c`'s `my_alloc()` all call the capacity-check functions directly, not only via `sched_try_alloc_on_host_()`. A private `static` helper with no other callers besides the functions being migrated should be migrated alongside them (leaving it stale forces an ugly cast, which this codebase's own design explicitly forbids in shared code).
|
||||
- **Task 1.2**: retyping a widely-called function's signature (e.g. `plugin_job_election`, `plugin_prepare_allocation`, `plugin_commit_decision`) breaks ALL of its call sites as hard compile errors in one step (this toolchain treats `-Wincompatible-pointer-types` as an error, not a warning) — there is no way to migrate a signature and keep the build green without touching every call site in the same commit, even when those call sites live in files nominally owned by a later task. The correct scope is the *minimal* fix (wrap the existing argument, e.g. `sched` → `&(sched->core)`; touch nothing else in that function), not a rewrite of the caller. Also: design.md's Implementation Notes said `plugin_prepare_allocation()` has "one normal-mode call site" — it actually has two (`resource.c`'s `sched_try_alloc_on_host_()` and `schedobj.c`'s `sched_ctx_set_primary()`). Grep for ALL call sites before assuming a design doc's count is exhaustive.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue