From 3cb97031a2a3d26a0c8bc0ec45bc9a6893ddd2f7 Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Wed, 22 Mar 2006 20:55:22 +0000 Subject: [PATCH] Tweak re-use of slurm_jobid in batch job, only use it if expliclty set on srun execute line, do not re-use it from the SLURM_JOBID env var (which prevents submitting a series of batch jobs). --- src/srun/opt.c | 2 ++ src/srun/opt.h | 1 + src/srun/srun.c | 7 ++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/srun/opt.c b/src/srun/opt.c index b63ccef85f0..90426a00d5f 100644 --- a/src/srun/opt.c +++ b/src/srun/opt.c @@ -679,6 +679,7 @@ static void _opt_default() opt.job_name = NULL; opt.jobid = NO_VAL; + opt.jobid_set = false; opt.dependency = NO_VAL; opt.account = NULL; @@ -1360,6 +1361,7 @@ void set_options(const int argc, char **argv, int first) break; case LONG_OPT_JOBID: opt.jobid = _get_int(optarg, "jobid"); + opt.jobid_set = true; break; case LONG_OPT_TIMEO: opt.msg_timeout = diff --git a/src/srun/opt.h b/src/srun/opt.h index 6bc83fd6c4c..feb411eefa9 100644 --- a/src/srun/opt.h +++ b/src/srun/opt.h @@ -106,6 +106,7 @@ typedef struct srun_options { distribution; /* --distribution=, -m dist */ char *job_name; /* --job-name=, -J name */ unsigned int jobid; /* --jobid=jobid */ + bool jobid_set; /* true of jobid explicitly set */ char *mpi_type; /* --mpi=type */ unsigned int dependency;/* --dependency, -P jobid */ int nice; /* --nice */ diff --git a/src/srun/srun.c b/src/srun/srun.c index 39c13a8a8a7..e8308739a37 100644 --- a/src/srun/srun.c +++ b/src/srun/srun.c @@ -458,9 +458,10 @@ _run_batch_job(void) if (!(req = job_desc_msg_create_from_opts (script))) fatal ("Unable to create job request"); - /* Do not re-use existing job id when submitting new job - * from within a running job */ - req->job_id = NO_VAL; + /* Do not re-use existing job id from environment variable + * when submitting new job from within a running job */ + if (opt.jobid_set != NO_VAL) + req->job_id = (uint32_t)opt.jobid; retries = 0; while ( (retries < MAX_RETRIES) -- GitLab