This will be fixed in version 2.5.5. Patch attached if you want it now.

Moe


Quoting Michael Gutteridge <[email protected]>:


Hi all

Running into an interesting issue with exporting environment
variables.  I'm still on 2.3.5, but I wasn't able to locate anything
in changelogs that suggests behavior that's been fixed.

Anyway- I'm passing parameters to scripts using environment variables:

foo=bar bar=baz sbatch --export=foo,bar -J myname myscript.sh

foo and bar are being set properly, but the SLURM environment variable
"SLURM_JOB_NAME" goes missing (i.e. unset).  If I remove the export or
(and this is interesting) set "--export=ALL", then I will have
SLURM_JOB_NAME set properly for the job.

Is this expected behavior?  Obviously I've got the workaround (setting
export to all), but it's a little inelegant IMHO.

Thanks

Michael


diff --git a/src/sbatch/sbatch.c b/src/sbatch/sbatch.c
index 0a2d87d..2b2a927 100644
--- a/src/sbatch/sbatch.c
+++ b/src/sbatch/sbatch.c
@@ -230,6 +230,14 @@ static void _env_merge_filter(job_desc_msg_t *desc)
 		tok = strtok_r(NULL, ",", &last);
 	}
 	xfree(tmp);
+
+	for (i = 0; environ[i]; i++) {
+		if (strncmp("SLURM_", environ[i], 6))
+			continue;
+		save_env[0] = environ[i];
+		env_array_merge(&desc->environment,
+				(const char **)save_env);
+	}
 }
 
 /* Returns SLURM_ERROR if settings are invalid for chosen cluster */

Reply via email to