Skip to content

Commit 4f7d5b1

Browse files
committed
flux-job: remove manual jobspec reconstruction
Problem: flux job info manually reconstructs a current jobspec from the jobspec and eventlog. However the job-info.lookup service w/ the CURRENT flag could be used instead. Update code to use the lookup service w/ current flag instead of manually reconstructing the current jobspec.
1 parent 003f8e7 commit 4f7d5b1

File tree

1 file changed

+3
-61
lines changed

1 file changed

+3
-61
lines changed

src/cmd/flux-job.c

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,42 +3308,6 @@ int cmd_wait_event (optparse_t *p, int argc, char **argv)
33083308
return (0);
33093309
}
33103310

3311-
char *reconstruct_current_jobspec (const char *jobspec_str,
3312-
const char *eventlog_str)
3313-
{
3314-
json_t *jobspec;
3315-
json_t *eventlog;
3316-
size_t index;
3317-
json_t *entry;
3318-
char *result;
3319-
3320-
if (!(jobspec = json_loads (jobspec_str, 0, NULL)))
3321-
log_msg_exit ("error decoding jobspec");
3322-
if (!(eventlog = eventlog_decode (eventlog_str)))
3323-
log_msg_exit ("error decoding eventlog");
3324-
json_array_foreach (eventlog, index, entry) {
3325-
const char *name;
3326-
json_t *context;
3327-
3328-
if (eventlog_entry_parse (entry, NULL, &name, &context) < 0)
3329-
log_msg_exit ("error decoding eventlog entry");
3330-
if (streq (name, "jobspec-update")) {
3331-
const char *path;
3332-
json_t *value;
3333-
3334-
json_object_foreach (context, path, value) {
3335-
if (jpath_set (jobspec, path, value) < 0)
3336-
log_err_exit ("failed to update jobspec");
3337-
}
3338-
}
3339-
}
3340-
if (!(result = json_dumps (jobspec, JSON_COMPACT)))
3341-
log_msg_exit ("failed to encode jobspec object");
3342-
json_decref (jobspec);
3343-
json_decref (eventlog);
3344-
return result;
3345-
}
3346-
33473311
void info_usage (void)
33483312
{
33493313
fprintf (stderr,
@@ -3403,33 +3367,11 @@ int cmd_info (optparse_t *p, int argc, char **argv)
34033367
log_msg_exit ("Failed to unwrap J to get jobspec: %s", error.text);
34043368
val = new_val;
34053369
}
3406-
/* The current (non --base) jobspec has to be reconstructed by fetching
3407-
* the jobspec and the eventlog and updating the former with the latter.
3408-
*/
3409-
else if (!optparse_hasopt (p, "base") && streq (key, "jobspec")) {
3410-
const char *jobspec;
3411-
const char *eventlog;
3412-
3413-
// fetch the two keys in parallel
3414-
if (!(f = flux_rpc_pack (h,
3415-
"job-info.lookup",
3416-
FLUX_NODEID_ANY,
3417-
0,
3418-
"{s:I s:[ss] s:i}",
3419-
"id", id,
3420-
"keys", "jobspec", "eventlog",
3421-
"flags", 0))
3422-
|| flux_rpc_get_unpack (f,
3423-
"{s:s s:s}",
3424-
"jobspec", &jobspec,
3425-
"eventlog", &eventlog) < 0)
3426-
log_msg_exit ("%s", future_strerror (f, errno));
3427-
val = new_val = reconstruct_current_jobspec (jobspec, eventlog);
3428-
}
3429-
/* The current (non --base) R is obtained through the
3370+
/* The current (non --base) R and jobspec are obtained through the
34303371
* job-info.lookup RPC w/ the CURRENT flag.
34313372
*/
3432-
else if (!optparse_hasopt (p, "base") && streq (key, "R")) {
3373+
else if (!optparse_hasopt (p, "base")
3374+
&& (streq (key, "R") || streq (key, "jobspec"))) {
34333375
if (!(f = flux_rpc_pack (h,
34343376
"job-info.lookup",
34353377
FLUX_NODEID_ANY,

0 commit comments

Comments
 (0)