diff --git a/src/srun/allocate.c b/src/srun/allocate.c index 868ae4c890dcb3514e861531d3b8b73d903d3f5d..cbbdf404e7bd01e4f5f4a884876845a58478cd72 100644 --- a/src/srun/allocate.c +++ b/src/srun/allocate.c @@ -164,7 +164,9 @@ existing_allocation(void) uint32_t old_job_id; resource_allocation_response_msg_t *resp = NULL; - if ((old_job_id = jobid_from_env()) == 0) + if (opt.jobid != NO_VAL) + old_job_id = (uint32_t)opt.jobid; + else return NULL; if (slurm_allocation_lookup_lite(old_job_id, &resp) < 0) { @@ -183,19 +185,6 @@ existing_allocation(void) return resp; } -/* - * Returns jobid if SLURM_JOBID was set in the user's environment - * or if --jobid option was given, else returns 0 - */ -uint32_t -jobid_from_env(void) -{ - if (opt.jobid != NO_VAL) - return ((uint32_t) opt.jobid); - else - return (0); -} - static void _wait_for_resources(resource_allocation_response_msg_t **resp) { diff --git a/src/srun/srun.c b/src/srun/srun.c index 62852140d967c2aaac6f970f5244ea92c05c621c..4fc771128f14c5fd80451f3c807fe247b7928001 100644 --- a/src/srun/srun.c +++ b/src/srun/srun.c @@ -100,12 +100,10 @@ #define TYPE_SCRIPT 2 -typedef resource_allocation_response_msg_t allocation_resp; - /* * forward declaration of static funcs */ -static void _print_job_information(allocation_resp *resp); +static void _print_job_information(resource_allocation_response_msg_t *resp); static char *_build_script (char *pathname, int file_type); static char *_get_shell (void); static void _send_options(const int argc, char **argv); @@ -127,7 +125,7 @@ static int _run_srun_script (srun_job_t *job, char *script); int srun(int ac, char **av) { - allocation_resp *resp; + resource_allocation_response_msg_t *resp; srun_job_t *job = NULL; int exitcode = 0; env_t *env = xmalloc(sizeof(env_t)); @@ -239,6 +237,16 @@ 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", @@ -474,7 +482,7 @@ _switch_standalone(srun_job_t *job) static void -_print_job_information(allocation_resp *resp) +_print_job_information(resource_allocation_response_msg_t *resp) { int i; char tmp_str[10], job_details[4096];