fix(controller,xceadmin): fix zero-slot scheduling block, misleading resval logs, byte-unit display
Three bugs found while diagnosing a live controller log, all in the worker resource-value path: 1. Every host relying on the documented hosts.yaml auto-detect default (no max_slot, meaning "use CPU count") got 0 scheduling slots, permanently blocking the scheduler from placing jobs on it. mxj is UInt32 on the wire and can't carry the schema's -1 sentinel; mapping.py worked around this by leaving it unset, which defaults to 0 -- and 0 is never < 0, so apply_join_state()'s auto-detect fallback never fired. Fixed by encoding the sentinel as 0xFFFFFFFF, which the controller's `int mxj` field reinterprets back to -1 via its existing implicit uint32_t->int conversion. No C-side or wire schema change needed for this part; the fallback itself was already correct but had zero test coverage for a negative mxj, now added. 2. update_resvals()/update_resval_list() logged the failure reason via PERROR, which reads process-global errno -- but update_resval()'s failure paths return raw negative codes directly and never touch errno, so the controller log filled with misleading "update_resval: Success" / "update_resval: Resource temporarily unavailable" lines instead of the real reason. Fixed to decode the actual rc via xce_strerror_r and name the failing resource. 3. maxmem is canonically stored/wired as raw bytes but had no unit metadata, so resval/workerlist printed it as a bare number that read as garbage (e.g. workerlist's fixed-width columns visually smeared a multi-GB byte count across the MaxCPU/MaxMem headers). Added an optional `unit` field to the Resource/ResourceVal capnp structs (and xce_resource_t/xce_resval_t/resources.yaml) so resval and workerlist can render a human-readable value (e.g. "30.90 GB") while the stored value stays raw bytes -- display-only, every other resource unaffected. Regenerated the xceadmin golden fixture (fixtures/full/expected.bin) twice: once for the mxj sentinel encoding change, once for the new Resource.unit field growing every resource's wire size by one pointer slot. Both diffs verified byte-for-byte isolated to exactly the expected change before regenerating. Verified: 1095/1095 controller_unit_test (stable across repeated runs), 229/229 xceadmin pytest, clean rebuild of lib/controller/xceadmin/xce_test. Two related findings logged to .wolf/buglog.json but deliberately not fixed here (out of scope per discussion): a pre-existing flaky segfault in the combined controller_unit_test binary, and maxswap/maxtmp being hardcoded stub values on the worker side. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
9e15161228
commit
e3b3ffaa97
12 changed files with 354 additions and 20 deletions
|
|
@ -1050,6 +1050,9 @@ static char* worker_status_str(uint32_t status)
|
|||
return "UNKOWN";
|
||||
}
|
||||
|
||||
/* forward decl: defined near cmd_resval, below, which also uses it */
|
||||
static void format_bytes_human(double bytes, char* buf, size_t bufsize);
|
||||
|
||||
int cmd_workerlist(int argc, char* argv[])
|
||||
{
|
||||
int rc, i;
|
||||
|
|
@ -1068,11 +1071,19 @@ int cmd_workerlist(int argc, char* argv[])
|
|||
"MaxSwap", "MaxTmp", "NDisks");
|
||||
|
||||
for (i = 0; i < rc; i++) {
|
||||
printf("%-20s%-8s%-25s%-25s%12f%12d%12f%12f%12f%12d\n",
|
||||
/* MaxMem is stored/wired as raw bytes (xce_resource_t.unit="bytes"
|
||||
* for the maxmem resource definition) -- humanize for display only,
|
||||
* every other column stays as-is. */
|
||||
char maxmem_buf[64];
|
||||
|
||||
format_bytes_human(workers[i]->attrs->maxmem, maxmem_buf,
|
||||
sizeof(maxmem_buf));
|
||||
|
||||
printf("%-20s%-8s%-25s%-25s%12f%12d%12s%12f%12f%12d\n",
|
||||
workers[i]->name, worker_status_str(workers[i]->status),
|
||||
workers[i]->attrs->hosttype, workers[i]->attrs->hostmodel,
|
||||
workers[i]->attrs->cpufactor, workers[i]->attrs->maxcpus,
|
||||
workers[i]->attrs->maxmem, workers[i]->attrs->maxswap,
|
||||
maxmem_buf, workers[i]->attrs->maxswap,
|
||||
workers[i]->attrs->maxtmp, workers[i]->attrs->ndisks);
|
||||
}
|
||||
|
||||
|
|
@ -2024,6 +2035,28 @@ cleanup:
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Render a raw byte count as a human-readable string (e.g. "30.90 GB").
|
||||
* Only used for display -- the stored/wire value stays raw bytes always,
|
||||
* this never feeds back into anything that's compared or persisted. A
|
||||
* pure function so it's directly unit-testable without a live client
|
||||
* connection.
|
||||
*/
|
||||
static void format_bytes_human(double bytes, char* buf, size_t bufsize)
|
||||
{
|
||||
static const char* const UNITS[] = { "B", "KB", "MB", "GB", "TB", "PB" };
|
||||
const int nunits = (int)(sizeof(UNITS) / sizeof(UNITS[0]));
|
||||
double val = bytes;
|
||||
int i = 0;
|
||||
|
||||
while (val >= 1024.0 && i < nunits - 1) {
|
||||
val /= 1024.0;
|
||||
i++;
|
||||
}
|
||||
|
||||
snprintf(buf, bufsize, "%.2f %s", val, UNITS[i]);
|
||||
}
|
||||
|
||||
int cmd_resval(int argc, char* argv[])
|
||||
{
|
||||
char* host = NULL;
|
||||
|
|
@ -2065,7 +2098,15 @@ int cmd_resval(int argc, char* argv[])
|
|||
printf("%s\n", val->val->u.svalue);
|
||||
break;
|
||||
case Value_u_fvalue:
|
||||
printf("%f\n", val->val->u.fvalue);
|
||||
if ((val->unit != NULL) && (strcmp(val->unit, "bytes") == 0)) {
|
||||
char hbuf[64];
|
||||
|
||||
format_bytes_human(val->val->u.fvalue, hbuf,
|
||||
sizeof(hbuf));
|
||||
printf("%f (%s)\n", val->val->u.fvalue, hbuf);
|
||||
} else {
|
||||
printf("%f\n", val->val->u.fvalue);
|
||||
}
|
||||
break;
|
||||
case Value_u_bvalue:
|
||||
printf("%s\n", (val->val->u.bvalue == 0) ? "false" : "true");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue