Scheduling controller: per-node allocatability check (shared fit logic)
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 368
Description
Extract the per-agent resource fit-check logic and add a read-only allocatability check method on the scheduling controller, reusing the SAME logic as real scheduling to avoid drift.
## Scope
- Extract the fit-check in sokovan/scheduler/provisioner/selectors/selector.py (_check_tracker_compatibility, ~line 501: available_slots = agent.available_slots - occupied_slots; compare to requested_slots; collect insufficient slots) into a shared pure function used by both real scheduling and this check.
- Add SchedulingController.check_allocatability(spec) -> AllocatabilityResult, mirroring the existing read-only validate_session_spec pattern.
- Load candidate agent occupancy snapshot via repository, scoped to the given scaling group; run the shared fit function per node.
- Return per_agent fit results; for non-fitting nodes include insufficient slots (requested vs available) ordered by resource_slot_types.rank DESCENDING (reverse rank: scarce/accelerator first).
- allocatable = any(node fits). No side effects (no allocation/reservation).
- Define the AllocatabilityResult data type.
## Out of scope
- Policy-based limits (keypair/group/domain). Resource-only.
## Success Criteria
- [ ] sufficient: one node has available >= requested -> allocatable=true, that node fits=true
- [ ] insufficient: all nodes short on >=1 slot -> allocatable=false, each node lists insufficient slots with requested/available
- [ ] multi-slot shortage on a node -> insufficient slots ordered by rank descending (accelerator before cpu/mem)
- [ ] shared fit function is used by both the scheduler selection path and check_allocatability (no duplicated comparison logic)
- [ ] check_allocatability performs no DB writes / no allocation side effects
- [ ] pants test passes for affected packages
JIRA Issue: BA-6563
Contributor guide
Research direction
Start in sokovan/scheduler/provisioner/selectors/selector.py at _check_tracker_compatibility and compare it with the existing validate_session_spec pattern. Trace how the repository loads the scaling group's candidate-agent occupancy snapshot, then identify the affected scheduler packages and their Pants tests. Done means both scheduling paths use the shared fit logic, results include ranked shortages, and the check has no allocation or database-write side effects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100