Skip to content

Commit e06f20f

Browse files
committed
job-list: use f58 for jobid in log messages
Problem: job-list logs jobids in their decimal encoding, but jobids in this form aren't easily identifiable as jobids at first glance and take up more space in most cases. Update the job-list module use f58 encoding where possible.
1 parent 6524773 commit e06f20f

File tree

2 files changed

+63
-61
lines changed

2 files changed

+63
-61
lines changed

src/modules/job-list/job_data.c

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "src/common/librlist/rnode.h"
2323
#include "src/common/libccan/ccan/str/str.h"
2424
#include "src/common/libjob/jj.h"
25+
#include "src/common/libjob/idf58.h"
2526

2627
#include "job_data.h"
2728

@@ -104,8 +105,8 @@ static int parse_jobspec_job_name (struct job *job,
104105
"{s?:s}",
105106
"name", &job->name) < 0) {
106107
flux_log (job->h, LOG_ERR,
107-
"%s: job %ju invalid job dictionary: %s",
108-
__FUNCTION__, (uintmax_t)job->id, error.text);
108+
"%s: job %s invalid job dictionary: %s",
109+
__FUNCTION__, idf58 (job->id), error.text);
109110
return -1;
110111
}
111112
}
@@ -120,23 +121,23 @@ static int parse_jobspec_job_name (struct job *job,
120121
"[{s:o}]",
121122
"command", &command) < 0) {
122123
flux_log (job->h, LOG_ERR,
123-
"%s: job %ju invalid jobspec: %s",
124-
__FUNCTION__, (uintmax_t)job->id, error.text);
124+
"%s: job %s invalid jobspec: %s",
125+
__FUNCTION__, idf58 (job->id), error.text);
125126
return -1;
126127
}
127128

128129
if (!json_is_array (command)) {
129130
flux_log (job->h, LOG_ERR,
130-
"%s: job %ju invalid jobspec",
131-
__FUNCTION__, (uintmax_t)job->id);
131+
"%s: job %s invalid jobspec",
132+
__FUNCTION__, idf58 (job->id));
132133
return -1;
133134
}
134135

135136
arg0 = json_array_get (command, 0);
136137
if (!arg0 || !json_is_string (arg0)) {
137138
flux_log (job->h, LOG_ERR,
138-
"%s: job %ju invalid job command",
139-
__FUNCTION__, (uintmax_t)job->id);
139+
"%s: job %s invalid job command",
140+
__FUNCTION__, idf58 (job->id));
140141
return -1;
141142
}
142143
job->name = parse_job_name (json_string_value (arg0));
@@ -181,8 +182,8 @@ static int parse_per_resource (struct job *job,
181182
"options",
182183
"per-resource", &o) < 0) {
183184
flux_log (job->h, LOG_ERR,
184-
"%s: job %ju invalid jobspec: %s",
185-
__FUNCTION__, (uintmax_t)job->id, error.text);
185+
"%s: job %s invalid jobspec: %s",
186+
__FUNCTION__, idf58 (job->id), error.text);
186187
return -1;
187188
}
188189

@@ -193,8 +194,8 @@ static int parse_per_resource (struct job *job,
193194
"type", type,
194195
"count", count) < 0) {
195196
flux_log (job->h, LOG_ERR,
196-
"%s: job %ju invalid per-resource spec: %s",
197-
__FUNCTION__, (uintmax_t)job->id, error.text);
197+
"%s: job %s invalid per-resource spec: %s",
198+
__FUNCTION__, idf58 (job->id), error.text);
198199
return -1;
199200
}
200201
}
@@ -269,8 +270,8 @@ static int parse_jobspec (struct job *job, const char *s, bool allow_nonfatal)
269270

270271
if (!(job->jobspec = json_loads (s, 0, &error))) {
271272
flux_log (job->h, LOG_ERR,
272-
"%s: job %ju invalid jobspec: %s",
273-
__FUNCTION__, (uintmax_t)job->id, error.text);
273+
"%s: job %s invalid jobspec: %s",
274+
__FUNCTION__, idf58 (job->id), error.text);
274275
goto error;
275276
}
276277

@@ -281,16 +282,16 @@ static int parse_jobspec (struct job *job, const char *s, bool allow_nonfatal)
281282
"job",
282283
&jobspec_job) < 0) {
283284
flux_log (job->h, LOG_ERR,
284-
"%s: job %ju invalid jobspec: %s",
285-
__FUNCTION__, (uintmax_t)job->id, error.text);
285+
"%s: job %s invalid jobspec: %s",
286+
__FUNCTION__, idf58 (job->id), error.text);
286287
goto nonfatal_error;
287288
}
288289

289290
if (jobspec_job) {
290291
if (!json_is_object (jobspec_job)) {
291292
flux_log (job->h, LOG_ERR,
292-
"%s: job %ju invalid jobspec",
293-
__FUNCTION__, (uintmax_t)job->id);
293+
"%s: job %s invalid jobspec",
294+
__FUNCTION__, idf58 (job->id));
294295
goto nonfatal_error;
295296
}
296297
}
@@ -299,8 +300,8 @@ static int parse_jobspec (struct job *job, const char *s, bool allow_nonfatal)
299300
"{s:o}",
300301
"tasks", &tasks) < 0) {
301302
flux_log (job->h, LOG_ERR,
302-
"%s: job %ju invalid jobspec: %s",
303-
__FUNCTION__, (uintmax_t)job->id, error.text);
303+
"%s: job %s invalid jobspec: %s",
304+
__FUNCTION__, idf58 (job->id), error.text);
304305
goto nonfatal_error;
305306
}
306307

@@ -314,15 +315,15 @@ static int parse_jobspec (struct job *job, const char *s, bool allow_nonfatal)
314315
"cwd", &job->cwd,
315316
"queue", &job->queue) < 0) {
316317
flux_log (job->h, LOG_ERR,
317-
"%s: job %ju invalid jobspec: %s",
318-
__FUNCTION__, (uintmax_t)job->id, error.text);
318+
"%s: job %s invalid jobspec: %s",
319+
__FUNCTION__, idf58 (job->id), error.text);
319320
goto nonfatal_error;
320321
}
321322

322323
if (jj_get_counts_json (job->jobspec, &jj) < 0) {
323324
flux_log (job->h, LOG_ERR,
324-
"%s: job %ju invalid jobspec; %s",
325-
__FUNCTION__, (uintmax_t)job->id, jj.error);
325+
"%s: job %s invalid jobspec; %s",
326+
__FUNCTION__, idf58 (job->id), jj.error);
326327
goto nonfatal_error;
327328
}
328329

@@ -371,8 +372,8 @@ static int parse_R (struct job *job, const char *s, bool allow_nonfatal)
371372

372373
if (!(job->R = json_loads (s, 0, &error))) {
373374
flux_log (job->h, LOG_ERR,
374-
"%s: job %ju invalid R: %s",
375-
__FUNCTION__, (uintmax_t)job->id, error.text);
375+
"%s: job %s invalid R: %s",
376+
__FUNCTION__, idf58 (job->id), error.text);
376377
goto nonfatal_error;
377378
}
378379

src/modules/job-list/job_state.c

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "src/common/libutil/jpath.h"
2525
#include "src/common/libutil/grudgeset.h"
2626
#include "src/common/libjob/job_hash.h"
27+
#include "src/common/libjob/idf58.h"
2728
#include "src/common/libidset/idset.h"
2829
#include "ccan/str/str.h"
2930

@@ -282,8 +283,8 @@ static void state_depend_lookup_continuation (flux_future_t *f, void *arg)
282283
assert (jsctx);
283284

284285
if (flux_rpc_get_unpack (f, "{s:s}", "jobspec", &s) < 0) {
285-
flux_log_error (jsctx->h, "%s: error jobspec for %ju",
286-
__FUNCTION__, (uintmax_t)job->id);
286+
flux_log_error (jsctx->h, "%s: error jobspec for %s",
287+
__FUNCTION__, idf58 (job->id));
287288
goto out;
288289
}
289290

@@ -332,8 +333,8 @@ static void state_run_lookup_continuation (flux_future_t *f, void *arg)
332333
assert (jsctx);
333334

334335
if (flux_rpc_get_unpack (f, "{s:s}", "R", &s) < 0) {
335-
flux_log_error (jsctx->h, "%s: error eventlog for %ju",
336-
__FUNCTION__, (uintmax_t)job->id);
336+
flux_log_error (jsctx->h, "%s: error eventlog for %s",
337+
__FUNCTION__, idf58 (job->id));
337338
goto out;
338339
}
339340

@@ -555,8 +556,8 @@ static struct job *eventlog_restart_parse (struct job_state_ctx *jsctx,
555556
goto error;
556557

557558
if (!(a = eventlog_decode (eventlog))) {
558-
flux_log_error (jsctx->h, "%s: error parsing eventlog for %ju",
559-
__FUNCTION__, (uintmax_t)job->id);
559+
flux_log_error (jsctx->h, "%s: error parsing eventlog for %s",
560+
__FUNCTION__, idf58 (job->id));
560561
goto error;
561562
}
562563

@@ -566,8 +567,8 @@ static struct job *eventlog_restart_parse (struct job_state_ctx *jsctx,
566567
json_t *context = NULL;
567568

568569
if (eventlog_entry_parse (value, &timestamp, &name, &context) < 0) {
569-
flux_log_error (jsctx->h, "%s: error parsing entry for %ju",
570-
__FUNCTION__, (uintmax_t)job->id);
570+
flux_log_error (jsctx->h, "%s: error parsing entry for %s",
571+
__FUNCTION__, idf58 (job->id));
571572
goto error;
572573
}
573574

@@ -839,15 +840,15 @@ static int job_update_eventlog_seq (struct job_state_ctx *jsctx,
839840
return 0;
840841
if (latest_eventlog_seq <= job->eventlog_seq) {
841842
flux_log (jsctx->h, LOG_INFO,
842-
"%s: job %ju duplicate event (last = %d, latest = %d)",
843-
__FUNCTION__, (uintmax_t)job->id,
843+
"%s: job %s duplicate event (last = %d, latest = %d)",
844+
__FUNCTION__, idf58 (job->id),
844845
job->eventlog_seq, latest_eventlog_seq);
845846
return 1;
846847
}
847848
if (latest_eventlog_seq > (job->eventlog_seq + 1))
848849
flux_log (jsctx->h, LOG_INFO,
849-
"%s: job %ju missed event (last = %d, latest = %d)",
850-
__FUNCTION__, (uintmax_t)job->id,
850+
"%s: job %s missed event (last = %d, latest = %d)",
851+
__FUNCTION__, idf58 (job->id),
851852
job->eventlog_seq, latest_eventlog_seq);
852853
job->eventlog_seq = latest_eventlog_seq;
853854
return 0;
@@ -912,8 +913,8 @@ static int submit_context_parse (flux_t *h,
912913
"urgency", &urgency,
913914
"userid", &userid,
914915
"version", &version) < 0) {
915-
flux_log (h, LOG_ERR, "%s: submit context invalid: %ju",
916-
__FUNCTION__, (uintmax_t)job->id);
916+
flux_log (h, LOG_ERR, "%s: submit context invalid: %s",
917+
__FUNCTION__, idf58 (job->id));
917918
errno = EPROTO;
918919
return -1;
919920
}
@@ -963,8 +964,8 @@ static int priority_context_parse (flux_t *h,
963964
|| json_unpack (context,
964965
"{ s:I }",
965966
"priority", (json_int_t *)&job->priority) < 0) {
966-
flux_log (h, LOG_ERR, "%s: priority context invalid: %ju",
967-
__FUNCTION__, (uintmax_t)job->id);
967+
flux_log (h, LOG_ERR, "%s: priority context invalid: %s",
968+
__FUNCTION__, idf58 (job->id));
968969
errno = EPROTO;
969970
return -1;
970971
}
@@ -1003,8 +1004,8 @@ static int finish_context_parse (flux_t *h,
10031004
|| json_unpack (context,
10041005
"{ s:i }",
10051006
"status", &job->wait_status) < 0) {
1006-
flux_log (h, LOG_ERR, "%s: finish context invalid: %ju",
1007-
__FUNCTION__, (uintmax_t)job->id);
1007+
flux_log (h, LOG_ERR, "%s: finish context invalid: %s",
1008+
__FUNCTION__, idf58 (job->id));
10081009
errno = EPROTO;
10091010
return -1;
10101011
}
@@ -1045,8 +1046,8 @@ static int urgency_context_parse (flux_t *h,
10451046
|| json_unpack (context, "{ s:i }", "urgency", &urgency) < 0
10461047
|| (urgency < FLUX_JOB_URGENCY_MIN
10471048
|| urgency > FLUX_JOB_URGENCY_MAX)) {
1048-
flux_log (h, LOG_ERR, "%s: urgency context invalid: %ju",
1049-
__FUNCTION__, (uintmax_t)job->id);
1049+
flux_log (h, LOG_ERR, "%s: urgency context invalid: %s",
1050+
__FUNCTION__, idf58 (job->id));
10501051
errno = EPROTO;
10511052
return -1;
10521053
}
@@ -1077,8 +1078,8 @@ static int exception_context_parse (flux_t *h,
10771078
"type", &type,
10781079
"severity", &severity,
10791080
"note", &note) < 0) {
1080-
flux_log (h, LOG_ERR, "%s: exception context invalid: %ju",
1081-
__FUNCTION__, (uintmax_t)job->id);
1081+
flux_log (h, LOG_ERR, "%s: exception context invalid: %s",
1082+
__FUNCTION__, idf58 (job->id));
10821083
errno = EPROTO;
10831084
return -1;
10841085
}
@@ -1106,8 +1107,8 @@ static int dependency_add (struct job *job,
11061107
&& errno != EEXIST)
11071108
/* Log non-EEXIST errors, but it is not fatal */
11081109
flux_log_error (job->h,
1109-
"job %ju: dependency-add",
1110-
(uintmax_t) job->id);
1110+
"job %s: dependency-add",
1111+
idf58 (job->id));
11111112
return 0;
11121113
}
11131114

@@ -1119,8 +1120,8 @@ static int dependency_remove (struct job *job,
11191120
/* No matching dependency is non-fatal error */
11201121
flux_log (job->h,
11211122
LOG_DEBUG,
1122-
"job %ju: dependency-remove '%s' not found",
1123-
(uintmax_t) job->id,
1123+
"job %s: dependency-remove '%s' not found",
1124+
idf58 (job->id),
11241125
description);
11251126
rc = 0;
11261127
}
@@ -1140,8 +1141,8 @@ static int dependency_context_parse (flux_t *h,
11401141
"{s:s}",
11411142
"description", &description) < 0) {
11421143
flux_log (h, LOG_ERR,
1143-
"job %ju: dependency-%s context invalid",
1144-
(uintmax_t) job->id,
1144+
"job %s: dependency-%s context invalid",
1145+
idf58 (job->id),
11451146
cmd);
11461147
errno = EPROTO;
11471148
return -1;
@@ -1153,8 +1154,8 @@ static int dependency_context_parse (flux_t *h,
11531154
rc = dependency_remove (job, description);
11541155
else {
11551156
flux_log (h, LOG_ERR,
1156-
"job %ju: invalid dependency event: dependency-%s",
1157-
(uintmax_t) job->id,
1157+
"job %s: invalid dependency event: dependency-%s",
1158+
idf58 (job->id),
11581159
cmd);
11591160
return -1;
11601161
}
@@ -1166,7 +1167,7 @@ static int memo_update (flux_t *h,
11661167
json_t *o)
11671168
{
11681169
if (!o) {
1169-
flux_log (h, LOG_ERR, "%ju: invalid memo context", (uintmax_t) job->id);
1170+
flux_log (h, LOG_ERR, "%s: invalid memo context", idf58 (job->id));
11701171
errno = EPROTO;
11711172
return -1;
11721173
}
@@ -1214,8 +1215,8 @@ static int journal_annotations_event (struct job_state_ctx *jsctx,
12141215
if (!context
12151216
|| json_unpack (context, "{ s:o }", "annotations", &annotations) < 0) {
12161217
flux_log (jsctx->h, LOG_ERR,
1217-
"%s: annotations event context invalid: %ju",
1218-
__FUNCTION__, (uintmax_t)job->id);
1218+
"%s: annotations event context invalid: %s",
1219+
__FUNCTION__, idf58 (job->id));
12191220
errno = EPROTO;
12201221
return -1;
12211222
}
@@ -1299,9 +1300,9 @@ static int journal_process_event (struct job_state_ctx *jsctx, json_t *event)
12991300
if (!job && !streq (name, "submit")) {
13001301
flux_log (jsctx->h,
13011302
LOG_ERR,
1302-
"event %s: job %ju not in hash",
1303+
"event %s: job %s not in hash",
13031304
name,
1304-
(uintmax_t) id);
1305+
idf58 (id));
13051306
return 0;
13061307
}
13071308

0 commit comments

Comments
 (0)