Skip to content

Commit

Permalink
job-list: improve journal error handling
Browse files Browse the repository at this point in the history
Problem: ENODATA is not treated specially (as per RFC 6) when
the journal RPC gets an error response.

Detect that case, log it, and stop the reactor without error.
Also, don't decode the eventlog initally, as it is not used yet.
Let any (unlikely) protocol errors be handled when the message is
processed.
  • Loading branch information
garlick committed Mar 28, 2024
1 parent 7f729b0 commit 4f85507
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/modules/job-list/job_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,10 @@ static int journal_process_events (struct job_state_ctx *jsctx,
"id", &id,
"events", &events) < 0)
return -1;
if (!json_is_array (events)) {
errno = EPROTO;
return -1;

Check warning on line 1302 in src/modules/job-list/job_state.c

View check run for this annotation

Codecov / codecov/patch

src/modules/job-list/job_state.c#L1301-L1302

Added lines #L1301 - L1302 were not covered by tests
}
json_array_foreach (events, index, value) {
if (journal_process_event (jsctx, id, value) < 0)
return -1;
Expand All @@ -1310,20 +1314,15 @@ static void job_events_journal_continuation (flux_future_t *f, void *arg)
struct job_state_ctx *jsctx = arg;
const flux_msg_t *msg;
flux_jobid_t id;
json_t *events;

if (flux_future_get (f, (const void **)&msg) < 0
|| flux_msg_unpack (msg,
"{s:I s:o}",
"id", &id,
"events", &events) < 0) {
flux_log_error (jsctx->h, "error unpacking journal response");
goto error;
}

if (!json_is_array (events)) {
flux_log (jsctx->h, LOG_ERR, "%s: events EPROTO", __FUNCTION__);
errno = EPROTO;
if (flux_rpc_get_unpack (f, "{s:I}", "id", &id) < 0
|| flux_future_get (f, (const void **)&msg) < 0) {
if (errno == ENODATA) {
flux_log (jsctx->h, LOG_INFO, "journal: EOF (exiting)");
flux_reactor_stop (flux_get_reactor (jsctx->h));
return;
}
flux_log (jsctx->h, LOG_ERR, "journal: %s", future_strerror (f, errno));

Check warning on line 1325 in src/modules/job-list/job_state.c

View check run for this annotation

Codecov / codecov/patch

src/modules/job-list/job_state.c#L1325

Added line #L1325 was not covered by tests
goto error;
}

Expand Down

0 comments on commit 4f85507

Please sign in to comment.