fix(scheduler): percent-based limit display shows raw fraction, not percent (bug-1831)
fmt_limit()/fmt_limit_units() formatted a percent-based limit's value as a bare snprintf(..., "%f%%", limit->val.val) -- echoing the raw stored value with a literal "%" appended. But xce_limit_val_t.val is genuinely a 0-1 fraction when percent is set (confirmed end-to-end: no /100 or *100 scaling exists anywhere in the config->capnp->runtime pipeline; confirmed authoritative by the original hand-written C literal this codebase's oldest percent-based limit was migrated from, .val = 0.2 for a documented "20% mem cap"). A correctly-configured 20% limit therefore displayed as "0.200000%" instead of "20.000000%" -- misleading, though technically an honest echo of the stored value. Fixed by multiplying by 100.0 before formatting. Display-only -- update_limit_res_value()'s actual capacity computation was already correct and is untouched. fmt_limit() (a thin XCE_UNITS_RAW wrapper) inherits this fix for its own percent-branch output too, a deliberate, intentional change from its pre-fix behavior for percent-based limits specifically (its 5 pre-existing direct tests only assert rc > 0, never the exact percent string, so this is safe). Updated test_limit.c's percent-mode test fixture from an unrealistic .val=80.0 to a realistic .val=0.8 (assertion text unchanged, since 0.8*100=80 either way) and test_repl_limit_table.c's own percent test to expect its shared fixture's arbitrary .val=50.0 constant correctly rendering as "5000.000000%". RED confirmed via the raw Unity testlog's :FAIL: lines (the aggregate meson summary masks single-test failures, a known harness quirk in this project); GREEN confirmed after, both lib and scheduler suites, 0 Unity FAILs. Discovered during live manual verification of scheduler-sim-diagnostics Requirement 6 against a real deployed cluster. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
parent
07b5c989b5
commit
0ce7125481
4 changed files with 103 additions and 14 deletions
|
|
@ -455,7 +455,7 @@ static void test_fmt_limit_units_percent_limit_ignores_units_mode(void)
|
|||
.hosts = NULL,
|
||||
.projects = NULL,
|
||||
.val
|
||||
= &(xce_limit_val_t) { .resname = "mem", .percent = 1, .val = 80.0 }
|
||||
= &(xce_limit_val_t) { .resname = "mem", .percent = 1, .val = 0.8 }
|
||||
};
|
||||
char buf[1024];
|
||||
xce_units_mode_t modes[] = { XCE_UNITS_RAW, XCE_UNITS_HUMAN,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue