Skip to content

Commit e509de4

Browse files
authored
Merge pull request #146 from ParaToolsInc/spank-debug-log
Fix SPINDLE_DEBUG + SPINDLE_TEST in SPANK plugin
2 parents e731f24 + bde3ab3 commit e509de4

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/slurm_plugin/slurm_plugin.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static int set_spindle_args(spank_t spank, spindle_args_t *params, int argc, cha
5353
static int get_spindle_args(spank_t spank, spindle_args_t *params);
5454
#endif
5555

56+
static int forward_environment_to_slurmstepd(spank_t spank);
5657
static int launchFE(char **hostlist, spindle_args_t *params);
5758
static int launchBE(spank_t spank, spindle_args_t *params);
5859
static int prepApp(spank_t spank, spindle_args_t *params);
@@ -80,6 +81,32 @@ struct spank_option spank_options[] =
8081
SPANK_OPTIONS_TABLE_END
8182
};
8283

84+
static int forward_environment_to_slurmstepd(spank_t spank)
85+
{
86+
char *debugEnv, *testEnv, *tmpEnv;
87+
88+
debugEnv= readSpankEnv(spank, "SPINDLE_DEBUG");
89+
testEnv = readSpankEnv(spank, "SPINDLE_TEST");
90+
tmpEnv = readSpankEnv(spank, "TMPDIR");
91+
92+
if (debugEnv) {
93+
setenv("SPINDLE_DEBUG", debugEnv, 1);
94+
free(debugEnv);
95+
}
96+
97+
if (testEnv) {
98+
setenv("SPINDLE_TEST", testEnv, 1);
99+
free(testEnv);
100+
}
101+
102+
if (tmpEnv) {
103+
setenv("TMPDIR", tmpEnv, 1);
104+
free(tmpEnv);
105+
}
106+
107+
return 0;
108+
}
109+
83110
int slurm_spank_task_init(spank_t spank, int site_argc, char *site_argv[])
84111
{
85112
spank_context_t context;
@@ -107,8 +134,13 @@ int slurm_spank_task_init(spank_t spank, int site_argc, char *site_argv[])
107134
return 0;
108135
}
109136

110-
push_env(spank, &env);
137+
// We need to acquire the job environment before we do anything that
138+
// will spawn the log daemon so that SPINDLE_DEBUG and SPINDLE_TEST
139+
// are set appropriately.
140+
forward_environment_to_slurmstepd(spank);
141+
111142
sdprintf(1, "Beginning spindle plugin\n");
143+
push_env(spank, &env);
112144

113145
result = process_spindle_args(spank, site_argc, site_argv, &params, NULL, NULL);
114146
if (result == -1) {

0 commit comments

Comments
 (0)