diff --git a/src/srun/srun.c b/src/srun/srun.c index 4fc771128f14c5fd80451f3c807fe247b7928001..7628c50fbbaf2b1ca80fdb019a3f680ebff9fcdd 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 a605a5d7339611b4e5476e33bfc271b10b4d6115..1f1c72d1634b320b0350b8dcbc298b1e1afe707e 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; /*