Skip to content

Commit

Permalink
fixup! job-manager: update running jobs if necessary after R update
Browse files Browse the repository at this point in the history
  • Loading branch information
grondo committed Oct 30, 2023
1 parent a4a2fa2 commit ffac57c
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/modules/job-manager/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <math.h>

#include <flux/core.h>

#include "src/common/libutil/errprintf.h"
Expand Down Expand Up @@ -653,29 +651,36 @@ static void resource_update_cb (flux_future_t *f, void *arg)
}
job = zlistx_first (jobs);
while (job) {
double expiration;
if (job->state & FLUX_JOB_STATE_RUNNING && job->R_redacted) {
double expiration = 0.;
double duration = 0.;
/*
* Get current job expiration and jobspec duration.
* Assume the expiration job of the job needs to be updated
* only if and expiration was set for the job _and_ the job
* duration was unset or 0. This indicates that the expiration
* was likely automatically set by the scheduler based on
* the instance expiration (which is now being updated).
*
*/
if (json_unpack (job->R_redacted,
"{s:{s:F}}",
"execution",
"expiration", &expiration) < 0) {
"expiration", &expiration) < 0
|| json_unpack (job->jobspec_redacted,
"{s:{s:{s?F}}",
"attributes",
"system",
"duration", &duration) < 0) {
flux_log (h,
LOG_ERR,
"%s: failed to unpack current expiration for update",
"failed to unpack job %s data for expiration update",
idf58 (job->id));
}

/*
* Only update the expiration of jobs where the old expiration
* exactly matches the previous resource set expiration. It
* should be safe to directly compare the two double precision
* expiration values, since the scheduler should have set the
* expiration of jobs to the exact value of the previous value,
* however, some schedulers may work in time_t or other integral
* values for starttime and expiration (e.g. Fluxion), so check
* for a difference of up to 1s just in case.
/* Job needs an update if no or unlimited duration specified
* (duration == 0.) but an expiration was set (expiration > 0.):
*/
if (fabs (expiration - old_expiration) < 1.) {
if (expiration > 0. && duration == 0.) {
flux_log (h,
LOG_DEBUG,
"adjusting expiration of %s from %.2f to %.2f",
Expand Down

0 comments on commit ffac57c

Please sign in to comment.