fix(worker): job ids print human-readable format via fmt_jobid() (bug-1588)
Extends bug-1588's job.c fix to the remaining raw-%lu jobid logging sites: 8 worker daemon files (xcecd_worker.c, controller_connector.c, uv_ipc.c, xcecd_worker_utils.c, xcecd_dbus_manager.c, xcecd.c, main.c, xcecd_cgroups.c) and src/controller/testsuite/test.c (xce_test, heavily used for controller testing). 99 call sites converted to fmt_jobid()+%s, matching the existing convention. Non-jobid %lu values (lsn, client id, byte offset) and raw-numeric identifier/path construction (checkpoint dir, systemd unit name, XCE_JOBID env var) are deliberately left untouched. Verified via /xce-build worker and controller (asan, --incremental): both compile clean with zero warnings tied to the change; worker suite 4/4 OK, controller suite 4/5 OK (the one failure is the pre-existing bug-1561 overlayfs fdatasync flake, unrelated to this change). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
811b5a11ec
commit
1c906e955c
9 changed files with 289 additions and 163 deletions
|
|
@ -2562,6 +2562,7 @@ int cmd_jobkill(int argc, char* argv[])
|
|||
int rc;
|
||||
xce_jobctrl_t jobctrl;
|
||||
xce_signal_t siginfo;
|
||||
char jobidStr[64];
|
||||
|
||||
optind = 1;
|
||||
signo = SIGTERM;
|
||||
|
|
@ -2596,7 +2597,8 @@ int cmd_jobkill(int argc, char* argv[])
|
|||
return rc;
|
||||
}
|
||||
|
||||
printf("Job %lu signaled\n", jobid);
|
||||
fmt_jobid(jobidStr, sizeof(jobidStr) - 1, jobid);
|
||||
printf("Job %s signaled\n", jobidStr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2608,6 +2610,7 @@ int cmd_jobckpt(int argc, char* argv[])
|
|||
int rc;
|
||||
xce_jobctrl_t jobctrl;
|
||||
xce_ckpt_options_t ckptoption;
|
||||
char jobidStr[64];
|
||||
|
||||
optind = 1;
|
||||
ckptoption.kill = 0;
|
||||
|
|
@ -2646,7 +2649,8 @@ int cmd_jobckpt(int argc, char* argv[])
|
|||
return rc;
|
||||
}
|
||||
|
||||
printf("Job %lu checkpointed\n", jobid);
|
||||
fmt_jobid(jobidStr, sizeof(jobidStr) - 1, jobid);
|
||||
printf("Job %s checkpointed\n", jobidStr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -3904,6 +3908,7 @@ static int run_task_local(uint64_t jobid, job_startinfo_t* startinfo,
|
|||
int ntasks)
|
||||
{
|
||||
pid_t pid;
|
||||
char jobidStr[64];
|
||||
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
|
|
@ -3963,7 +3968,8 @@ static int run_task_local(uint64_t jobid, job_startinfo_t* startinfo,
|
|||
exit(rc);
|
||||
}
|
||||
|
||||
printf("Job %lu started, PID: %d\n", jobid, pid);
|
||||
fmt_jobid(jobidStr, sizeof(jobidStr) - 1, jobid);
|
||||
printf("Job %s started, PID: %d\n", jobidStr, pid);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
|
@ -4037,21 +4043,27 @@ static int handle_startjob(xce_request_t* request)
|
|||
static int handle_notify(xce_request_t* request)
|
||||
{
|
||||
xce_notify_data_t* data = request->body.notifymsg;
|
||||
char jobidStr[64];
|
||||
|
||||
switch (data->event) {
|
||||
case NotifyData_data_taskPidInfo:
|
||||
printf("job %lu host %s taskidx %d pid %d\n",
|
||||
data->data.taskinfo->jobid, data->data.taskinfo->host,
|
||||
fmt_jobid(jobidStr, sizeof(jobidStr) - 1, data->data.taskinfo->jobid);
|
||||
printf("job %s host %s taskidx %d pid %d\n",
|
||||
jobidStr, data->data.taskinfo->host,
|
||||
data->data.taskinfo->taskidx, data->data.taskinfo->pids[0]);
|
||||
break;
|
||||
case NotifyData_data_taskFailInfo:
|
||||
printf("job %lu host %s task %d error code %d\n",
|
||||
data->data.taskfailinfo->jobid, data->data.taskfailinfo->host,
|
||||
fmt_jobid(jobidStr, sizeof(jobidStr) - 1,
|
||||
data->data.taskfailinfo->jobid);
|
||||
printf("job %s host %s task %d error code %d\n",
|
||||
jobidStr, data->data.taskfailinfo->host,
|
||||
data->data.taskfailinfo->taskidx, data->data.taskfailinfo->code);
|
||||
break;
|
||||
case NotifyData_data_taskFinish:
|
||||
printf("job %lu host %s task %d exit code %d\n",
|
||||
data->data.taskfinish->jobid, data->data.taskfinish->host,
|
||||
fmt_jobid(jobidStr, sizeof(jobidStr) - 1,
|
||||
data->data.taskfinish->jobid);
|
||||
printf("job %s host %s task %d exit code %d\n",
|
||||
jobidStr, data->data.taskfinish->host,
|
||||
data->data.taskfinish->taskidx,
|
||||
data->data.taskfinish->exit_code);
|
||||
break;
|
||||
|
|
@ -4132,6 +4144,7 @@ static int handle_runtasks(xce_request_t* request)
|
|||
xce_taskrun_t* runmsg = request->body.runtaskmsg;
|
||||
int rc = 0;
|
||||
int i = 0;
|
||||
char jobidStr[64];
|
||||
#if 0
|
||||
job_startinfo_t startinfo;
|
||||
#endif
|
||||
|
|
@ -4152,7 +4165,8 @@ static int handle_runtasks(xce_request_t* request)
|
|||
return rc;
|
||||
}
|
||||
|
||||
printf("run task: jobid = %lu\n", runmsg->jobid);
|
||||
fmt_jobid(jobidStr, sizeof(jobidStr) - 1, runmsg->jobid);
|
||||
printf("run task: jobid = %s\n", jobidStr);
|
||||
printf("run task: user = %s\n", runmsg->taskhosts[0]->execuser);
|
||||
printf("run task: cmdline = %s\n", runmsg->taskhosts[0]->cmdline);
|
||||
printf("run task: exdata = %s\n", runmsg->taskhosts[0]->exdata);
|
||||
|
|
@ -4177,7 +4191,7 @@ static int handle_runtasks(xce_request_t* request)
|
|||
} else {
|
||||
int idx;
|
||||
|
||||
printf("job %lu task %d started, PID: %d\n", runmsg->jobid, i, pid);
|
||||
printf("job %s task %d started, PID: %d\n", jobidStr, i, pid);
|
||||
|
||||
idx = get_avail_run_task_slots();
|
||||
if (idx < 0) {
|
||||
|
|
@ -4282,6 +4296,7 @@ static void check_run_jobs()
|
|||
xcecli_notify_jobresume(active_ctx->ctx, run_jobs[i].jobid);
|
||||
} else if (WIFEXITED(wstatus) || WIFSIGNALED(wstatus)) {
|
||||
xce_jobfinish_t finish;
|
||||
char jobidStr[64];
|
||||
|
||||
finish.jobid = run_jobs[i].jobid;
|
||||
|
||||
|
|
@ -4291,7 +4306,8 @@ static void check_run_jobs()
|
|||
finish.exit_code = 128 + WTERMSIG(wstatus);
|
||||
}
|
||||
|
||||
printf("job %lu exit code %d\n", finish.jobid, finish.exit_code);
|
||||
fmt_jobid(jobidStr, sizeof(jobidStr) - 1, finish.jobid);
|
||||
printf("job %s exit code %d\n", jobidStr, finish.exit_code);
|
||||
xcecli_notify_jobfinish(active_ctx->ctx, &finish);
|
||||
run_jobs[i].jobid = 0;
|
||||
run_jobs[i].pid = 0;
|
||||
|
|
@ -4343,6 +4359,7 @@ static void check_run_tasks()
|
|||
.taskidx = run_tasks[i].taskid,
|
||||
.clientidx = run_tasks[i].clientidx,
|
||||
.exit_code = 0 };
|
||||
char jobidStr[64];
|
||||
|
||||
if (WIFEXITED(wstatus)) {
|
||||
finish.exit_code = WEXITSTATUS(wstatus);
|
||||
|
|
@ -4350,7 +4367,8 @@ static void check_run_tasks()
|
|||
finish.exit_code = 128 + WTERMSIG(wstatus);
|
||||
}
|
||||
|
||||
printf("job %lu task %d exit code %d\n", finish.jobid,
|
||||
fmt_jobid(jobidStr, sizeof(jobidStr) - 1, finish.jobid);
|
||||
printf("job %s task %d exit code %d\n", jobidStr,
|
||||
finish.taskidx, finish.exit_code);
|
||||
xcecli_notify_taskfinish(active_ctx->ctx, &finish);
|
||||
run_tasks[i].jobid = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue