fix(bug-1735): job memory/CPU usage always read 0 in scheduler replay

Two independent gaps in misc.c/job.c, both silently zeroing every real
job's resource-usage data:

- update_host_runusage() matched worker rusage report resnames
  "cputime"/"mem", but the real worker's collector
  (collect_job_rusages(), xcecd_cgroups.c) sends "cpu_time_sec"/
  "memory_rss" -- the two never matched, so cpu_time/mem_usage stayed
  at their calloc()'d zero for every non-simulated job. Aligned both
  sides, including xce_test's own simulated-worker fixture.
- update_job_rusages() had a standing FIXME: xce_job_runusage_t's
  job-level max_mem/avg_mem/used_mem/cpu_time were never derived from
  the per-host host_runusage[] entries. Added aggregate_job_runusage()
  (sum/max/avg across hosts) and wired it in right after the per-host
  update.

Added test_host_runusage.c (standalone unit test, mirrors
resval_typeresolve_unit_test's isolation pattern) plus the
controller_unit_test stub aggregate_job_runusage() needs since that
target excludes the real misc.c.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QxaSzHRB7pmYFp4cVnwkA
This commit is contained in:
Rongsong Shen 2026-08-30 15:07:33 +00:00
parent ccef561031
commit d8a37fa27a
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
7 changed files with 335 additions and 10 deletions

View file

@ -3193,13 +3193,14 @@ int update_job_rusages(cluster_t* c, endpoint_t* ep, xce_request_t* request)
update_host_runusage(&(j->job.run_usage), host, rusages->count,
rusages->usages);
/* bug-1735: derive job-level max_mem/avg_mem/used_mem/cpu_time from the
* per-host entries update_host_runusage() just updated -- replaces the
* standing "update other fields of job rusage later" FIXME. */
aggregate_job_runusage(j->job.run_usage);
update_pids(&(j->job.pidinfo), rusages->npids, rusages->pids);
update_pgids(&(j->job.pidinfo), rusages->npgids, rusages->pgids);
/* FIXME
* update other fields of job rusage later
*/
/* TEMP diagnostic (bug-1731 job-finish-notify-loss investigation).
* DEBUG3-gated -- see bug-1731's own "re-add before next occurrence"
* recommendation; the DEBUG3 log-retention bump (bug-1731 support,