Skip to content

Commit 8190b78

Browse files
authored
Merge pull request #5633 from chu11/issue5577_job_info_lookup_decode_update
job-info: add JSON_DECODE & CURRENT flags, deprecate job-info.update-lookup
2 parents 925bfc1 + cf89676 commit 8190b78

File tree

15 files changed

+600
-241
lines changed

15 files changed

+600
-241
lines changed

src/cmd/flux-job.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3398,7 +3398,7 @@ int cmd_info (optparse_t *p, int argc, char **argv)
33983398
"keys", "J",
33993399
"flags", 0))
34003400
|| flux_rpc_get_unpack (f, "{s:s}", "J", &val) < 0)
3401-
log_msg_exit ("%s", future_strerror (f, errno ));
3401+
log_msg_exit ("%s", future_strerror (f, errno));
34023402
if (!(new_val = flux_unwrap_string (val, false, NULL, &error)))
34033403
log_msg_exit ("Failed to unwrap J to get jobspec: %s", error.text);
34043404
val = new_val;
@@ -3423,27 +3423,23 @@ int cmd_info (optparse_t *p, int argc, char **argv)
34233423
"{s:s s:s}",
34243424
"jobspec", &jobspec,
34253425
"eventlog", &eventlog) < 0)
3426-
log_msg_exit ("%s", future_strerror (f, errno ));
3426+
log_msg_exit ("%s", future_strerror (f, errno));
34273427
val = new_val = reconstruct_current_jobspec (jobspec, eventlog);
34283428
}
34293429
/* The current (non --base) R is obtained through the
3430-
* job-info.update-lookup RPC, not the normal job-info.lookup.
3430+
* job-info.lookup RPC w/ the CURRENT flag.
34313431
*/
34323432
else if (!optparse_hasopt (p, "base") && streq (key, "R")) {
3433-
json_t *o;
34343433
if (!(f = flux_rpc_pack (h,
3435-
"job-info.update-lookup",
3434+
"job-info.lookup",
34363435
FLUX_NODEID_ANY,
34373436
0,
3438-
"{s:I s:s s:i}",
3437+
"{s:I s:[s] s:i}",
34393438
"id", id,
3440-
"key", key,
3441-
"flags", 0))
3442-
|| flux_rpc_get_unpack (f, "{s:o}", key, &o) < 0)
3443-
log_msg_exit ("%s", future_strerror (f, errno ));
3444-
if (!(new_val = json_dumps (o, JSON_COMPACT)))
3445-
log_msg_exit ("error encoding R object");
3446-
val = new_val;
3439+
"keys", key,
3440+
"flags", FLUX_JOB_LOOKUP_CURRENT))
3441+
|| flux_rpc_get_unpack (f, "{s:s}", key, &val) < 0)
3442+
log_msg_exit ("%s", future_strerror (f, errno));
34473443
}
34483444
/* All other keys are obtained this way.
34493445
*/
@@ -3457,7 +3453,7 @@ int cmd_info (optparse_t *p, int argc, char **argv)
34573453
"keys", key,
34583454
"flags", 0))
34593455
|| flux_rpc_get_unpack (f, "{s:s}", key, &val) < 0)
3460-
log_msg_exit ("%s", future_strerror (f, errno ));
3456+
log_msg_exit ("%s", future_strerror (f, errno));
34613457
}
34623458

34633459
printf ("%s\n", val);

src/common/libjob/job.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ enum job_event_watch_flags {
3030
FLUX_JOB_EVENT_WATCH_WAITCREATE = 1, // wait for path to exist
3131
};
3232

33+
enum job_lookup_flags {
34+
/* return special fields as decoded JSON objects instead of strings
35+
* - currently works for jobspec and R
36+
*/
37+
FLUX_JOB_LOOKUP_JSON_DECODE = 1,
38+
/* get current value of special fields by applying eventlog
39+
* updates for those fields
40+
* - currently works for R
41+
*/
42+
FLUX_JOB_LOOKUP_CURRENT = 2,
43+
};
44+
3345
enum job_urgency {
3446
FLUX_JOB_URGENCY_MIN = 0,
3547
FLUX_JOB_URGENCY_HOLD = FLUX_JOB_URGENCY_MIN,

src/modules/job-info/job-info.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void stats_cb (flux_t *h, flux_msg_handler_t *mh,
3838
int lookups = zlist_size (ctx->lookups);
3939
int watchers = zlist_size (ctx->watchers);
4040
int guest_watchers = zlist_size (ctx->guest_watchers);
41-
int update_lookups = zlist_size (ctx->update_lookups);
41+
int update_lookups = 0; /* no longer supported */
4242
int update_watchers = update_watch_count (ctx);
4343
if (flux_respond_pack (h, msg, "{s:i s:i s:i s:i s:i}",
4444
"lookups", lookups,
@@ -117,8 +117,6 @@ static void info_ctx_destroy (struct info_ctx *ctx)
117117
guest_watch_cleanup (ctx);
118118
zlist_destroy (&ctx->guest_watchers);
119119
}
120-
if (ctx->update_lookups)
121-
zlist_destroy (&ctx->update_lookups);
122120
if (ctx->update_watchers) {
123121
update_watch_cleanup (ctx);
124122
zlist_destroy (&ctx->update_watchers);
@@ -147,8 +145,6 @@ static struct info_ctx *info_ctx_create (flux_t *h)
147145
goto error;
148146
if (!(ctx->guest_watchers = zlist_new ()))
149147
goto error;
150-
if (!(ctx->update_lookups = zlist_new ()))
151-
goto error;
152148
if (!(ctx->update_watchers = zlist_new ()))
153149
goto error;
154150
/* no destructor for index_uw, destruction handled on

src/modules/job-info/job-info.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ struct info_ctx {
2626
zlist_t *lookups;
2727
zlist_t *watchers;
2828
zlist_t *guest_watchers;
29-
zlist_t *update_lookups;
3029
zlist_t *update_watchers;
3130
zhashx_t *index_uw; /* update_watchers lookup */
3231
};

0 commit comments

Comments
 (0)