Skip to content

Commit

Permalink
Merge pull request #5633 from chu11/issue5577_job_info_lookup_decode_…
Browse files Browse the repository at this point in the history
…update

job-info: add JSON_DECODE & CURRENT flags, deprecate job-info.update-lookup
  • Loading branch information
mergify[bot] committed Feb 21, 2024
2 parents 925bfc1 + cf89676 commit 8190b78
Show file tree
Hide file tree
Showing 15 changed files with 600 additions and 241 deletions.
24 changes: 10 additions & 14 deletions src/cmd/flux-job.c
Original file line number Diff line number Diff line change
Expand Up @@ -3398,7 +3398,7 @@ int cmd_info (optparse_t *p, int argc, char **argv)
"keys", "J",
"flags", 0))
|| flux_rpc_get_unpack (f, "{s:s}", "J", &val) < 0)
log_msg_exit ("%s", future_strerror (f, errno ));
log_msg_exit ("%s", future_strerror (f, errno));
if (!(new_val = flux_unwrap_string (val, false, NULL, &error)))
log_msg_exit ("Failed to unwrap J to get jobspec: %s", error.text);
val = new_val;
Expand All @@ -3423,27 +3423,23 @@ int cmd_info (optparse_t *p, int argc, char **argv)
"{s:s s:s}",
"jobspec", &jobspec,
"eventlog", &eventlog) < 0)
log_msg_exit ("%s", future_strerror (f, errno ));
log_msg_exit ("%s", future_strerror (f, errno));
val = new_val = reconstruct_current_jobspec (jobspec, eventlog);
}
/* The current (non --base) R is obtained through the
* job-info.update-lookup RPC, not the normal job-info.lookup.
* job-info.lookup RPC w/ the CURRENT flag.
*/
else if (!optparse_hasopt (p, "base") && streq (key, "R")) {
json_t *o;
if (!(f = flux_rpc_pack (h,
"job-info.update-lookup",
"job-info.lookup",
FLUX_NODEID_ANY,
0,
"{s:I s:s s:i}",
"{s:I s:[s] s:i}",
"id", id,
"key", key,
"flags", 0))
|| flux_rpc_get_unpack (f, "{s:o}", key, &o) < 0)
log_msg_exit ("%s", future_strerror (f, errno ));
if (!(new_val = json_dumps (o, JSON_COMPACT)))
log_msg_exit ("error encoding R object");
val = new_val;
"keys", key,
"flags", FLUX_JOB_LOOKUP_CURRENT))
|| flux_rpc_get_unpack (f, "{s:s}", key, &val) < 0)
log_msg_exit ("%s", future_strerror (f, errno));
}
/* All other keys are obtained this way.
*/
Expand All @@ -3457,7 +3453,7 @@ int cmd_info (optparse_t *p, int argc, char **argv)
"keys", key,
"flags", 0))
|| flux_rpc_get_unpack (f, "{s:s}", key, &val) < 0)
log_msg_exit ("%s", future_strerror (f, errno ));
log_msg_exit ("%s", future_strerror (f, errno));
}

printf ("%s\n", val);
Expand Down
12 changes: 12 additions & 0 deletions src/common/libjob/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ enum job_event_watch_flags {
FLUX_JOB_EVENT_WATCH_WAITCREATE = 1, // wait for path to exist
};

enum job_lookup_flags {
/* return special fields as decoded JSON objects instead of strings
* - currently works for jobspec and R
*/
FLUX_JOB_LOOKUP_JSON_DECODE = 1,
/* get current value of special fields by applying eventlog
* updates for those fields
* - currently works for R
*/
FLUX_JOB_LOOKUP_CURRENT = 2,
};

enum job_urgency {
FLUX_JOB_URGENCY_MIN = 0,
FLUX_JOB_URGENCY_HOLD = FLUX_JOB_URGENCY_MIN,
Expand Down
6 changes: 1 addition & 5 deletions src/modules/job-info/job-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void stats_cb (flux_t *h, flux_msg_handler_t *mh,
int lookups = zlist_size (ctx->lookups);
int watchers = zlist_size (ctx->watchers);
int guest_watchers = zlist_size (ctx->guest_watchers);
int update_lookups = zlist_size (ctx->update_lookups);
int update_lookups = 0; /* no longer supported */
int update_watchers = update_watch_count (ctx);
if (flux_respond_pack (h, msg, "{s:i s:i s:i s:i s:i}",
"lookups", lookups,
Expand Down Expand Up @@ -117,8 +117,6 @@ static void info_ctx_destroy (struct info_ctx *ctx)
guest_watch_cleanup (ctx);
zlist_destroy (&ctx->guest_watchers);
}
if (ctx->update_lookups)
zlist_destroy (&ctx->update_lookups);
if (ctx->update_watchers) {
update_watch_cleanup (ctx);
zlist_destroy (&ctx->update_watchers);
Expand Down Expand Up @@ -147,8 +145,6 @@ static struct info_ctx *info_ctx_create (flux_t *h)
goto error;
if (!(ctx->guest_watchers = zlist_new ()))
goto error;
if (!(ctx->update_lookups = zlist_new ()))
goto error;
if (!(ctx->update_watchers = zlist_new ()))
goto error;
/* no destructor for index_uw, destruction handled on
Expand Down
1 change: 0 additions & 1 deletion src/modules/job-info/job-info.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct info_ctx {
zlist_t *lookups;
zlist_t *watchers;
zlist_t *guest_watchers;
zlist_t *update_lookups;
zlist_t *update_watchers;
zhashx_t *index_uw; /* update_watchers lookup */
};
Expand Down

0 comments on commit 8190b78

Please sign in to comment.