myxce/src/xceadmin/tests/fixtures/full/configs/limits.yaml
Rongsong Shen 7982f28557
feat(xceadmin): validate percent-based limit values are in [0.0, 1.0] (bug-1833)
Adds an if/then JSON Schema (draft 2020-12) conditional constraint to
limits.schema.json's Limit definition: when percent is true, value
must be a number in [0.0, 1.0]. This is the class of authoring mistake
bug-1831/bug-1832 fixed manually (night_mem_pct: value: 50 instead of
0.5) -- now caught automatically at real `xceadmin config build` time
(the actual cluster.bin generation path deploy-ha.sh uses), not merely
by a unit test.

Empirically verified against the real jsonschema library this repo
uses: a violation surfaces with the exact same file/json_pointer/
constraint contract validate_yaml()'s existing ValidationError already
provides, so zero changes were needed to its error-reporting code.

While implementing this, the new constraint caught an identical
pre-existing defect in xceadmin's own checked-in "full" golden test
fixture (fixtures/full/configs/limits.yaml, night_mem_pct: value: 50)
-- fixed the same way, and regenerated the checked-in expected.bin
golden artifact to match the corrected input.

Added 3 tests to test_validation.py: reject an out-of-range percent
value, accept an in-range one, and confirm a non-percent value is
never range-checked regardless of magnitude.

Build gotcha discovered and documented (cerebrum.md): this repo has
two copies of every bundled schema -- src/configs/schema/ (canonical)
and src/xceadmin/src/xcecommon/schema_files/json/ (a gitignored local
mirror meson-build.sh always overwrites from the canonical copy on
every build). Only the canonical copy needed a source-controlled edit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
2026-09-20 10:50:21 +00:00

51 lines
1.1 KiB
YAML

---
limits:
# cap total slots for ug1 across the whole cluster
- name: ug1_slots
users:
members:
- ug1
resname: slots
value: 10
# per-user slot cap inside ug2 (each member gets up to 4, not a shared pool)
- name: ug2_slots_per_user
users:
members:
- ug2
exclude_members:
- user3
resname: slots
value: 4
per_user: true
# queue-scoped memory cap, percentage of currently-available mem resource
# (bug-1831/1832: percent-based value is a 0-1 fraction, not a 0-100
# number -- 0.5 = 50%, matching src/configs/limits.yaml's own fix)
- name: night_mem_pct
queues:
members:
- night
resname: mem
value: 0.5
percent: true
# host-scoped cap, applied per host in hg1
- name: hg1_slots_per_host
hosts:
members:
- hg1
resname: slots
value: 20
per_host: true
# combined scope: ug1 members on the normal queue
- name: ug1_normal_slots
users:
members:
- ug1
queues:
members:
- normal
resname: slots
value: 8