refactor(controller,xceadmin): drop generic Resource.unit, hardcode bytes for maxmem

Simplification per review feedback on e3b3ffa: a generic schema-driven
unit field touched the capnp wire schema (2 structs), C structs
(xce_resource_t/xce_resval_t), resobj.c's deep-copy/destroy, opget.c's
reply-build lookup, resources.yaml/resources.schema.json, and mapping.py
-- real cross-cutting cost for a mechanism only one resource (maxmem)
actually needs today.

Reverted all of that. The controller CLI (test.c) now just knows
"maxmem" is bytes-valued via a small explicit is_bytes_valued_resource()
name list, and adaptively picks the best-fit human unit at display time
(format_bytes_human, unchanged) -- same observable behavior (resval/
workerlist render maxmem as e.g. "30.90 GB"), zero wire schema surface.
Regenerated the xceadmin golden fixture back to its pre-unit-field size
(5304 bytes, exactly matching the size right after the mxj-only fix,
confirming a clean, complete removal).

Verified: 1095/1095 controller_unit_test (3 runs; one hit the
pre-existing flaky segfault already logged as bug-1553, unrelated),
228/228 xceadmin pytest, clean rebuild of lib/controller/xceadmin/xce_test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-13 08:27:16 +00:00
parent e3b3ffaa97
commit 5bf123cc20
Signed by: rshen
SSH key fingerprint: SHA256:8Vf2pZ3h6rJa7EhGK+WaAQ9Mta/apZvteW6g9U/WKKk
10 changed files with 36 additions and 58 deletions

View file

@ -209,17 +209,6 @@ struct Resource $C.mapname("xce_resource_t"){
lastReport @7: UInt64 $C.mapname("last_report");
# distributions @8: List(ResourceDistribution) $C.maplistcount("ndistributions");
# hostBased @9: Value $C.mapname("hbased_defined");
# capnp requires ordinals to be sequential with no holes, so @8/@9 above
# (commented out, not yet implemented) cannot be skipped -- unit takes @8
# here; whoever implements distributions/hostBased will need to renumber
# them to @9/@10 rather than reclaiming @8.
# Optional display-unit hint (e.g. "bytes") for resources whose canonical
# internal value isn't already human-scale -- empty/unset means "raw
# number, no conversion" (every pre-existing resource, unaffected). CLI
# display (resval/workerlist) converts to a human-readable form for
# known units instead of the raw value; the stored/wire value itself
# stays canonical (e.g. maxmem stays bytes, never converted at rest).
unit @8: Text;
}
struct Threshold $C.mapname("xce_res_threshold_t"){
@ -357,9 +346,6 @@ struct ResourceVal $C.mapname("xce_resval_t") {
name @0: Text $C.mapname("name");
host @1: Text $C.mapname("host");
val @2: Value $C.mapname("val");
# Display-unit hint copied from the resource's own definition (Resource.unit)
# at reply-build time -- empty/unset means "raw number, no conversion".
unit @3: Text $C.mapname("unit");
}
struct ResourceVals $C.mapname("xce_resval_data_t") {