Skip to content
Snippets Groups Projects
Commit 16bbb9c4 authored by Moe Jette's avatar Moe Jette
Browse files

Restore some code removed in v1.2.

Required for test1.57 and moab use.
parent 3914f7e0
No related branches found
No related tags found
No related merge requests found
......@@ -114,7 +114,7 @@ allocate_nodes(void)
/* Do not re-use existing job id when submitting new job
* from within a running job */
if (getenv("SLURM_JOBID") != NULL) {
if ((j->job_id != NO_VAL) && !opt.jobid_set) {
info("WARNING: Creating SLURM job allocation from within "
"another allocation");
info("WARNING: You are attempting to initiate a second job");
......@@ -158,6 +158,31 @@ allocate_nodes(void)
return resp;
}
resource_allocation_response_msg_t *
existing_allocation(void)
{
uint32_t old_job_id;
resource_allocation_response_msg_t *resp = NULL;
if ((old_job_id = jobid_from_env()) == 0)
return NULL;
if (slurm_allocation_lookup(old_job_id, &resp) < 0) {
if (opt.parallel_debug || opt.jobid_set)
return NULL; /* create new allocation as needed */
if (errno == ESLURM_ALREADY_DONE)
error ("SLURM job %u has expired.", old_job_id);
else
error ("Unable to confirm allocation for job %u: %m",
old_job_id);
info ("Check SLURM_JOBID environment variable "
"for expired or invalid job.");
exit(1);
}
return resp;
}
/*
* Returns jobid if SLURM_JOBID was set in the user's environment
* or if --jobid option was given, else returns 0
......
......@@ -72,6 +72,14 @@ job_desc_msg_t * job_desc_msg_create_from_opts (char *script);
*/
void job_desc_msg_destroy (job_desc_msg_t *j);
/*
* Check for SLURM_JOBID environment variable, and if it is a valid
* jobid, return a pseudo allocation response pointer.
*
* Returns NULL if SLURM_JOBID is not present or is invalid.
*/
resource_allocation_response_msg_t * existing_allocation(void);
/*
* Return the jobid number stored in SLURM_JOBID env var
*
......
......@@ -238,7 +238,8 @@ int srun(int ac, char **av)
xfree(env);
exit (exitcode);
} else if ((job_id = jobid_from_env())) {
} else if ((resp = existing_allocation())) {
slurm_free_resource_allocation_response_msg(resp);
if (opt.allocate) {
error("job %u already has an allocation",
job_id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment