feat(scheduler-allocation): implement the shared host-candidate iterator
Adds host_iter.c: the one shared xce_host_iter_t implementation, lazily filtering sched->core.workers by select expression (sched_meet_host_selection, unchanged) and resource availability (sched_check_host_satisfy, unchanged), with a real cancellation point per candidate visited. xce_alloc_plan_t gains a ctx field (xce_sched_ctx_t*) so the iterator can reach the scheduler/select expression/staged resource-want -- additive to task 1.1's approved interface, NULL-guarded at init(). Test proves the core design property this spec exists to establish: a host too small for one search remains a valid candidate for a later, smaller search via a fresh iterator instance over the same worker set. Task 2.1 (scheduler-allocation spec). Requirements 3.1-3.6. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XYdtrEWWZfKRRGED7raEYg
This commit is contained in:
parent
d0024eb7e8
commit
d9831b0bc8
5 changed files with 872 additions and 2 deletions
|
|
@ -23,7 +23,7 @@
|
|||
- _Requirements: 4.2_
|
||||
|
||||
- [ ] 2. Core: shared allocation infrastructure
|
||||
- [ ] 2.1 (P) Implement and test the lazy host-candidate iterator
|
||||
- [x] 2.1 (P) Implement and test the lazy host-candidate iterator
|
||||
- Implement the shared host-candidate iterator against the existing select-expression evaluator and resource-availability check, with no allocator-specific logic
|
||||
- Ensure each call advances a real cancellation point so a long-running scan can be safely interrupted
|
||||
- Write a unit test proving a host too small for one candidate search remains a valid candidate for a later, smaller search using a freshly-initialized iterator over the same underlying worker set
|
||||
|
|
@ -106,6 +106,7 @@
|
|||
|
||||
## Implementation Notes
|
||||
|
||||
- (2.1) `xce_alloc_plan_t` gained a `ctx` field (`xce_sched_ctx_t*`) so `host_iter_init()` can reach `ctx->sched`/`ctx->primary->select`/`ctx->alloc_req.host` — `host_iter_init()` rejects a plan with `ctx == NULL` with `-EINVAL` rather than crashing. **Tasks 3.1 and 4.1 must set `plan->ctx = ctx` on every plan their plan-iterator returns from `next()`** (not just once) before constructing a `host_iter` from it — a plan-iterator that reuses one internal buffer across calls/jobs must refresh this field each time, since a stale-but-non-NULL pointer from a torn-down `ctx` is not caught by the NULL guard.
|
||||
- (1.4) When a new scheduler test needs a real function from `schedobj.c`/`core.c` (e.g. `sched_ctx_get_uncomit_host()`), white-box `#include` the real source file rather than privately reimplementing its logic in the test — established precedent: `test_picker_config_fields.c`'s `#include "../src/core.c"` + `#include "../src/schedobj.c"` pairing. A private reimplementation may pass today but silently drifts from the real function with nothing to catch it later.
|
||||
- (1.1) `xce_host_iter_t.next()` returns `xce_sched_worker_t*` (`sched/types.h`, carries `resvals`/`resInUse`/`host_eval_ctx`) — never `xce_worker_t*` (`xce/types.h`, the wire/config type `make_sched_worker()` converts FROM). requirements.md/design.md briefly had this wrong; fixed in commit `d1a3e158`. Task 2.1 (`host_iter.c`'s real implementation) and any later task touching worker candidates must use `xce_sched_worker_t*` from the start.
|
||||
- (1.2) `resreq_fp`'s ingest-time population lives in `core_build_primary_schedobj()` (`src/scheduler/src/core_events.c`), right after `primary->resreq = resreq;` — confirmed wired (min_tasks/max_tasks/select_node_id/rusage_hash all set from the parsed `xce_primary_resreq_t`) as of task 1.2 round 2, regression-covered by `test_core_build_primary_schedobj_populates_resreq_fp_from_parsed_resreq` in `src/scheduler/testsuite/test_core_events.c`. Round 1 added the type/field/hash machinery but never wired this call site, leaving `resreq_fp` permanently zeroed — do not rediscover this gap in a later task.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue