diff --git a/src/modules/job-list/job_data.c b/src/modules/job-list/job_data.c index a30286fbbaf1..db659502447d 100644 --- a/src/modules/job-list/job_data.c +++ b/src/modules/job-list/job_data.c @@ -460,18 +460,22 @@ static int parse_R (struct job *job, bool allow_nonfatal) return rc; } -int job_parse_R (struct job *job, const char *s) +int job_parse_R (struct job *job, const char *s, json_t *updates) { if (load_R (job, s, true) < 0) return -1; - return parse_R (job, true); + if (parse_R (job, true) < 0) + return -1; + return job_R_update (job, updates); } -int job_parse_R_fatal (struct job *job, const char *s) +int job_parse_R_fatal (struct job *job, const char *s, json_t *updates) { if (load_R (job, s, false) < 0) return -1; - return parse_R (job, false); + if (parse_R (job, false) < 0) + return -1; + return job_R_update (job, updates); } int job_jobspec_update (struct job *job, json_t *updates) diff --git a/src/modules/job-list/job_data.h b/src/modules/job-list/job_data.h index 98c5e96af298..98f37aba5281 100644 --- a/src/modules/job-list/job_data.h +++ b/src/modules/job-list/job_data.h @@ -127,12 +127,12 @@ int job_jobspec_update (struct job *job, json_t *updates); * - ncores * - ntasks (if necessary) */ -int job_parse_R (struct job *job, const char *s); +int job_parse_R (struct job *job, const char *s, json_t *updates); /* identical to above, but all nonfatal errors will return error. * Primarily used for testing. */ -int job_parse_R_fatal (struct job *job, const char *s); +int job_parse_R_fatal (struct job *job, const char *s, json_t *updates); /* Update R with RFC21 defined keys * (i.e. "expiration") and value. diff --git a/src/modules/job-list/job_state.c b/src/modules/job-list/job_state.c index 37f965aae057..efc2067f82e9 100644 --- a/src/modules/job-list/job_state.c +++ b/src/modules/job-list/job_state.c @@ -359,7 +359,7 @@ static void state_run_lookup_continuation (flux_future_t *f, void *arg) goto out; } - if (job_parse_R (job, s) < 0) + if (job_parse_R (job, s, NULL) < 0) goto out; updt = zlist_head (job->updates); @@ -852,7 +852,7 @@ static int depthfirst_map_one (struct job_state_ctx *jsctx, if (flux_kvs_lookup_get (f3, &R) < 0) goto done; - if (job_parse_R (job, R) < 0) + if (job_parse_R (job, R, NULL) < 0) goto done; } diff --git a/src/modules/job-list/test/job_data.c b/src/modules/job-list/test/job_data.c index aad5c289c428..ad65147fbf03 100644 --- a/src/modules/job-list/test/job_data.c +++ b/src/modules/job-list/test/job_data.c @@ -328,7 +328,7 @@ static int parse_R (struct job *job, const char *filename) read_file (filename, (void **)&data); - ret = job_parse_R_fatal (job, data); + ret = job_parse_R_fatal (job, data, NULL); free (data); return ret; @@ -821,23 +821,28 @@ static void test_R_update (void) read_file (filename, (void **)&data); - if (job_parse_R (job, data) < 0) + if (!(o = json_pack ("{s:f}", "expiration", 100.0))) + BAIL_OUT ("json_pack failed"); + + if (job_parse_R (job, data, o) < 0) BAIL_OUT ("cannot load basic R"); + json_decref (o); + ret = json_unpack (job->R, "{s:{s:F}}", "execution", "expiration", &expiration); ok (ret == 0, "parsed initial R expiration"); - ok (expiration == 0.0, "initial R expiration == 0.0"); - ok (job->expiration == 0.0, "initial job->expiration == 0.0"); + ok (expiration == 100.0, "initial R expiration == 100.0"); + ok (job->expiration == 100.0, "initial job->expiration == 100.0"); ret = job_R_update (job, NULL); ok (ret == 0, "job_R_update success with no update"); if (!(o = json_pack ("{s:f s:s}", - "expiration", 100.0, + "expiration", 200.0, "dummy", "dummy"))) BAIL_OUT ("json_pack failed"); ret = job_R_update (job, o); @@ -850,8 +855,8 @@ static void test_R_update (void) "expiration", &expiration); ok (ret == 0, "parsed updated R expiration"); - ok (expiration == 100.0, "R expiration == 100.0"); - ok (job->expiration == 100.0, "job->expiration == 100.0"); + ok (expiration == 200.0, "R expiration == 200.0"); + ok (job->expiration == 200.0, "job->expiration == 200.0"); ret = json_unpack (job->R, "{s?s}", "dummy", &tmp); ok (ret == 0, "parsed updated R dummy");