Pre-existing uncommitted work: ha-repl-hardening payload data plane (7.x), heartbeat liveness fix (Req 1.3), connection-reuse ASAN fixes, doc cleanup. New: ha-consistency-invariants umbrella (requirements/design/research) and its four implementation sub-specs (specs generated via batch, cross-spec review applied), steering roadmap + product.md Raft+CP decision.
2.2 KiB
2.2 KiB
P1-2: Host Resource Requirement Select — Investigation
Status
- C layer (P1-2a): COMPLETE —
eval_select_simplewired inxce_select.c(PEG grammar → AST → CSE, memoized eval). Scheduler integration (Phase 6) done. Seesrc/docs/resreq-ast-cse-design.mdfor architecture reference. - Go bridge (P1-2b): PENDING —
EvalSelectForHostremains a stub returningerrNoCGO. CGO boundary, resource value lookup from in-memory store, andFilterHostByResReqSelectare still to implement.
Background
The select field in an LSF-style resource requirement string (e.g.
select[mem>4096 && type==X86_64]) filters candidate hosts before slot
allocation. Currently EvalSelectForHost is a no-CGO stub that always returns
errNoCGO.
The full feature requires two layers:
- C parser + evaluator — parse the boolean select expression into an AST and evaluate it against a host's resource values.
- Go bridge — call the C evaluator via CGO and wire it into
FilterHostByResReqSelectin the controllers layer.
Sub-tasks
#11 P1-2a: C select expression parser (PEG + eval) ✓ COMPLETE
Files implemented:
include/resreq.h— expression-tree types, enums,externdeclarations.lib/xce_select.peg— PEG grammar for select boolean expressions.lib/xce_select.c—parse_select(),eval_select_simple(), CSE tree.lib/meson.build—xce_select.pegin build.
#12 P1-2b: Go EvalSelectForHost + FilterHostByResReqSelect (remaining)
Files to touch:
backend/clib.go— ImplementEvalSelectForHost(hostname, selectExpr string) errorusingcgo.Handlefor callback context; add#include "resreq.h", extern C declarations,xce_select_destroyhelper.controllers/hosts.go— ImplementFilterHostByResReqSelect(hosts []models.HostInfo, expr string), updatepreCheckHostRequest()limit from 4094 → 1024 bytes.
Open questions:
- Does
EvalSelectForHostlook up live resource values from the in-memory store, or are values passed directly from C? cgo.Handleusage pattern — per-call or session-level?- Input validation: max expression length (1024 bytes), allowed characters.