From 29f25688edfb4780f66788f65ed9135c06801d3e Mon Sep 17 00:00:00 2001 From: David Bigagli <david@schedmd.com> Date: Thu, 3 Dec 2015 13:57:09 +0100 Subject: [PATCH] Wait for prolog is already running. --- NEWS | 2 ++ src/slurmd/slurmd/req.c | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index ac0afd151cd..faddf300786 100644 --- a/NEWS +++ b/NEWS @@ -44,6 +44,8 @@ documents those changes that are of interest to users and administrators. correctly when PriorityFlags=CALCULATE_RUNNING is set. -- Add slurmdb_find_tres_count_in_string() to slurm db perl api. -- Make lua dlopen() conditional on version found at build. + -- When launching a task wait for the prolog to finish if it is still + running. * Changes in Slurm 15.08.4 ========================== diff --git a/src/slurmd/slurmd/req.c b/src/slurmd/slurmd/req.c index e8f635074e8..d3e367a0172 100644 --- a/src/slurmd/slurmd/req.c +++ b/src/slurmd/slurmd/req.c @@ -1184,7 +1184,7 @@ _rpc_launch_tasks(slurm_msg_t *msg) * Do not launch a new job step while prolog in progress: */ if (_prolog_is_running (req->job_id)) { - info("[job %u] prolog in progress\n", req->job_id); + info("[job %u] prolog in progress", req->job_id); errnum = EINPROGRESS; goto done; } @@ -5918,13 +5918,23 @@ static int _match_jobid(void *listentry, void *key) return (*job0 == *job1); } -static int _prolog_is_running (uint32_t jobid) +static int _prolog_is_running(uint32_t jobid) { - int rc = 0; - if (list_find_first (conf->prolog_running_jobs, - (ListFindF) _match_jobid, &jobid)) - rc = 1; - return (rc); + time_t start; + uint16_t timeout; + + timeout = slurm_get_prolog_timeout(); + start = time(NULL); + + while (time(NULL) - start < timeout) { + if (list_find_first (conf->prolog_running_jobs, + (ListFindF) _match_jobid, &jobid)) { + sleep(1); + continue; + } + return 0; + } + return 1; } /* Wait for the job's prolog to complete */ -- GitLab