fix show exec host for pend jobs

This commit is contained in:
Rongsong Shen 2026-05-09 04:09:16 +00:00
parent 064717959d
commit af578c29ca
3 changed files with 23 additions and 22 deletions

View file

@ -166,7 +166,7 @@ func (p *ArrayElementsPagePrinter) formatRows(jobs *models.JobsResponse, truncat
mainRow = appendOrDefault(mainRow, FormatStringField(job.FromHost, width, truncatFlag, true), "-")
case models.HEADER_JOB_EXEC_HOST:
var execHosts models.ExecHosts
if err := json.Unmarshal([]byte(job.ExecHosts.String()), &execHosts); err == nil && len(execHosts.HostSlots) > 0 {
if err := json.Unmarshal([]byte(job.ExecHosts.String()), &execHosts); err == nil && len(execHosts.HostSlots) > 0 && execHosts.HostSlots[0].HostName != "" {
firstHost := fmt.Sprintf("%d*%s", execHosts.HostSlots[0].NumSlots, execHosts.HostSlots[0].HostName)
mainRow = appendOrDefault(mainRow, FormatStringField(firstHost, width, truncatFlag, true), "-")

View file

@ -179,7 +179,7 @@ func (p *JobsPagePrinter) formatRows(jobs *models.JobsResponse, truncatFlag bool
case models.HEADER_JOB_EXEC_HOST:
var execHosts models.ExecHosts
if err := json.Unmarshal([]byte(job.ExecHosts.String()), &execHosts); err == nil && len(execHosts.HostSlots) > 0 {
if err := json.Unmarshal([]byte(job.ExecHosts.String()), &execHosts); err == nil && len(execHosts.HostSlots) > 0 && execHosts.HostSlots[0].HostName != "" {
firstHost := fmt.Sprintf("%d*%s", execHosts.HostSlots[0].NumSlots, execHosts.HostSlots[0].HostName)
mainRow = appendOrDefault(mainRow,
FormatStringField(firstHost, width, truncatFlag, false), "-")

View file

@ -22,14 +22,12 @@
static int sched_session_active(xce_scheduler_t* sched)
{
return atomic_load_explicit(&sched->session_active,
memory_order_acquire);
return atomic_load_explicit(&sched->session_active, memory_order_acquire);
}
static int sched_eval_in_progress(xce_scheduler_t* sched)
{
return atomic_load_explicit(&sched->eval_in_progress,
memory_order_acquire);
return atomic_load_explicit(&sched->eval_in_progress, memory_order_acquire);
}
static int sched_staging_merge_complete(xce_scheduler_t* sched)
@ -257,10 +255,10 @@ static void* sched_allocator(void* arg)
/* job is pend */
xce_pendreason_t* reason = job->schedobj->reason;
fmt_jobid(jobidString, sizeof(jobidString), jobid);
WARN("job %s is pending but pend reason is NULL", jobidString);
if (reason != NULL) {
if (reason == NULL) {
fmt_jobid(jobidString, sizeof(jobidString), jobid);
WARN("job %s is pending but pend reason is NULL", jobidString);
} else {
reason->jobid = job->jobid;
decision = make_pend_decision(reason);
}
@ -388,8 +386,8 @@ int sched_init(xce_scheduler_t* sched, xce_client_config_t* config,
sched->nextid = 1;
sched->configver = 0;
xstring_table_init(1024*1024);
xstring_table_init(1024 * 1024);
mylock_init(&(sched->lock));
cbuf_init(&(sched->wbuf), 1, sizeof(int));
cbuf_init(&(sched->jbuf), njobs, sizeof(uint64_t));
@ -448,7 +446,7 @@ int sched_init(xce_scheduler_t* sched, xce_client_config_t* config,
rc = xcecli_start(sched->apictx);
if (rc < 0) {
xcecli_ctx_fini(sched->apictx); /* free before next attempt */
xcecli_ctx_fini(sched->apictx); /* free before next attempt */
continue;
}
@ -489,7 +487,7 @@ int sched_init(xce_scheduler_t* sched, xce_client_config_t* config,
return rc;
}
void sched_set_cluster_cfg(xce_scheduler_t* sched,
void sched_set_cluster_cfg(xce_scheduler_t* sched,
const xce_cluster_config_t* cfg)
{
if (sched == NULL || cfg == NULL) {
@ -823,7 +821,8 @@ static int sched_account_jobs(xce_scheduler_t* sched)
void sched_begin_session(xce_scheduler_t* sched)
{
atomic_store_explicit(&sched->session_active, 1, memory_order_release);
atomic_store_explicit(&sched->staging_merge_complete, 0, memory_order_release);
atomic_store_explicit(&sched->staging_merge_complete, 0,
memory_order_release);
/* Allocate a fresh memoisation context sized to the current interned-node
* population. sched_reset_workers (called below) frees each worker's
@ -839,7 +838,8 @@ void sched_begin_session(xce_scheduler_t* sched)
sched_account_jobs(sched);
/* Staging merge done — sched_end_session's GC guard reads this field. */
atomic_store_explicit(&sched->staging_merge_complete, 1, memory_order_release);
atomic_store_explicit(&sched->staging_merge_complete, 1,
memory_order_release);
return;
}
@ -855,8 +855,7 @@ void sched_end_session(xce_scheduler_t* sched)
/* Guard: GC requires the evaluation pipeline to be idle */
if (sched_eval_in_progress(sched) || !sched_staging_merge_complete(sched)) {
TRACE("%s: GC skipped — eval_in_progress=%d staging_merge_complete=%d",
__func__,
sched_eval_in_progress(sched),
__func__, sched_eval_in_progress(sched),
sched_staging_merge_complete(sched));
return;
}
@ -878,8 +877,8 @@ void sched_end_session(xce_scheduler_t* sched)
}
if (njobs >= cap) {
int newcap = cap * 2;
xce_sched_job_t** tmp = realloc(live_jobs,
newcap * sizeof(*live_jobs));
xce_sched_job_t** tmp
= realloc(live_jobs, newcap * sizeof(*live_jobs));
if (tmp == NULL) {
free(live_jobs);
live_jobs = NULL;
@ -899,7 +898,8 @@ void sched_end_session(xce_scheduler_t* sched)
if (live_jobs == NULL) {
/* OOM: cannot safely GC — skip to avoid sweeping nodes still in use */
atomic_store_explicit(&sched->staging_merge_complete, 1, memory_order_release);
atomic_store_explicit(&sched->staging_merge_complete, 1,
memory_order_release);
return;
}
@ -951,7 +951,8 @@ void sched_end_session(xce_scheduler_t* sched)
recompact_node_ids();
free(live_jobs);
atomic_store_explicit(&sched->staging_merge_complete, 1, memory_order_release);
atomic_store_explicit(&sched->staging_merge_complete, 1,
memory_order_release);
}
int sched_add_job(xce_scheduler_t* sched, xce_sched_job_t* j)