From 169d62c86457f45dacd547088ea1bc1566031de7 Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Mon, 18 Sep 2006 20:34:22 +0000 Subject: [PATCH] fix to allow hostlists when they are requested instead of implying them --- src/srun/srun.c | 9 --------- src/srun/srun_job.c | 15 ++++++++++----- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/srun/srun.c b/src/srun/srun.c index 4fc771128f1..7628c50fbba 100644 --- a/src/srun/srun.c +++ b/src/srun/srun.c @@ -238,15 +238,6 @@ int srun(int ac, char **av) } else if ((resp = existing_allocation())) { job_id = resp->job_id; - /* If opt.nodelist isn't set we initialize it from the - * allocation info, but only if the env variable SLURM_HOSTFILE - * ISN'T set, because SLURM_HOSTFILE isn't parsed until - * job_step_create_allocation is called (bad design, all env - * variable parsing should happen up front in opt.c with the - * rest of the option parsing). - */ - if (opt.nodelist == NULL && getenv("SLURM_HOSTFILE") == NULL) - opt.nodelist = xstrdup(resp->node_list); slurm_free_resource_allocation_response_msg(resp); if (opt.allocate) { error("job %u already has an allocation", diff --git a/src/srun/srun_job.c b/src/srun/srun_job.c index a605a5d7339..1f1c72d1634 100644 --- a/src/srun/srun_job.c +++ b/src/srun/srun_job.c @@ -16,7 +16,7 @@ * any later version. * * In addition, as a special exception, the copyright holders give permission - * to link the code of portions of this program with the OpenSSL library under + * to link the code of portions of this program with the OpenSSL library under * certain conditions as described in each individual source file, and * distribute linked combinations including the two. You must obey the GNU * General Public License in all respects for all of the code used other than @@ -163,13 +163,18 @@ job_step_create_allocation(uint32_t job_id) if(!opt.max_nodes) opt.max_nodes = opt.min_nodes; - + + /* The reason we read in from the hostfile here is so if we don't + * need all the hostfile we only get what the user asked for + * (i.e. opt.max_nodes) + */ if (opt.nodelist == NULL) { char *nodelist = NULL; char *hostfile = getenv("SLURM_HOSTFILE"); if (hostfile != NULL) { - nodelist = slurm_read_hostfile(hostfile, opt.nprocs); + nodelist = slurm_read_hostfile(hostfile, + opt.max_nodes); if (nodelist == NULL) { error("Failure getting NodeNames from " "hostfile"); @@ -184,7 +189,7 @@ job_step_create_allocation(uint32_t job_id) } } ai->nodelist = opt.alloc_nodelist; - + if (opt.exc_nodes) { hostlist_t exc_hl = hostlist_create(opt.exc_nodes); char *node_name = NULL; @@ -308,7 +313,7 @@ job_step_create_allocation(uint32_t job_id) hostlist_uniq(hl); ai->nnodes = hostlist_count(hl); hostlist_destroy(hl); - } else if((opt.max_nodes > 0) && (opt.max_nodes <ai->nnodes)) + } else if((opt.max_nodes > 0) && (opt.max_nodes < ai->nnodes)) ai->nnodes = opt.max_nodes; /* -- GitLab