fix(frontend): count host job-state columns and EXEC_HOST by real slots

NJOBS/RUN/SSUSP/USUSP (xcecli hosts list -l) and EXEC_HOST (xcecli jobs
list) always showed a hardcoded 1 slot per host regardless of a job's
actual per-host allocation -- rawJobToModel()'s ExecHosts JSONB builder
never read the real per-host "slots" resource from the C job allocation,
so the already-correct downstream slot-counting logic (computeHostSlotUsage,
bug-1743) and EXEC_HOST's "N*host" formatter never had real data to work
with. convert.go now extracts each host's real slots allocation via a new
CGO indexing helper, mirroring the scheduler's own get_nslots_in_alloc()
convention.

Also wires hosts list -l's "CURRENT LOAD USED FOR SCHEDULING" table (tmp/
swap/mem/slots and friends) to the host's real live resource values --
previously entirely hardcoded placeholder strings, never connected to any
backend data.
This commit is contained in:
Rongsong Shen 2026-09-07 07:32:00 +00:00
parent f55b49f1a7
commit e395eaa3ad
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
5 changed files with 223 additions and 28 deletions

View file

@ -98,6 +98,24 @@ type XCEHost struct {
GPUTopo interface{} `json:"gpu_topo"` // JSONB
SchedStop SchedStop `json:"sched_stop"` // JSONB
RealLoad interface{} `json:"real_load"`
// ResourceValues carries this host's live per-resource wire values
// (r15s/r1m/r15m/ut/pg/io/ls/it/tmp/swp/mem/slots, among others), the
// same set the C scheduler's own "info worker" REPL command shows --
// populated by the apiserver from the worker's own resval pushes.
ResourceValues []ResourceDistributionInfo `json:"resource_values"`
}
// ResourceDistributionInfo mirrors apiserver/models.ResourceDistributionInfo's
// JSON shape -- one resource's current value for one host/worker.
type ResourceDistributionInfo struct {
ResourceName string `json:"res_name"`
IsDynamic bool `json:"is_dynamic"`
ValueType int `json:"value_type"`
BooleanValue bool `json:"boolean_value"`
StringValue string `json:"string_value"`
NumericValue float64 `json:"numeric_value"`
Location string `json:"location"`
}
var HostFieldsMap = map[string]string{
@ -135,20 +153,20 @@ type HostControlResponseItem struct {
HostName string `json:"host_name"`
Msg string `json:"msg"`
}
func (h *XCEHost) UnmarshalJSON(data []byte) error {
type Alias XCEHost
var a Alias
if err := UnmarshalOrderMapRow(data, &a); err != nil {
return err
}
*h = XCEHost(a)
return nil
}
type ResReqSelectRequest struct {
Select string `json:"select"`
Order string `json:"order,omitempty"`
Limit int `json:"limit,omitempty"`
PageToken string `json:"page_token,omitempty"`
}
func (h *XCEHost) UnmarshalJSON(data []byte) error {
type Alias XCEHost
var a Alias
if err := UnmarshalOrderMapRow(data, &a); err != nil {
return err
}
*h = XCEHost(a)
return nil
}
type ResReqSelectRequest struct {
Select string `json:"select"`
Order string `json:"order,omitempty"`
Limit int `json:"limit,omitempty"`
PageToken string `json:"page_token,omitempty"`
}