Skip to content

Commit 228107e

Browse files
committed
Pass the environment dict to all commands (query and cancel)
- Previously, only the query command got the full enivornment. - If this is used to authenticate to the submit/query/cancel commands, then the user's environment gets this also. - Closes: #108
1 parent c320f05 commit 228107e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

batchspawner/batchspawner.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def read_job_state(self):
250250
cmd = format_template(cmd, **subvars)
251251
self.log.debug('Spawner querying job: ' + cmd)
252252
try:
253-
out = yield self.run_command(cmd)
253+
out = yield self.run_command(cmd, env=self.get_env())
254254
self.job_status = out
255255
except Exception as e:
256256
self.log.error('Error querying job ' + self.job_id)
@@ -269,7 +269,7 @@ def cancel_batch_job(self):
269269
cmd = self.exec_prefix + ' ' + self.batch_cancel_cmd
270270
cmd = format_template(cmd, **subvars)
271271
self.log.info('Cancelling job ' + self.job_id + ': ' + cmd)
272-
yield self.run_command(cmd)
272+
yield self.run_command(cmd, env=self.get_env())
273273

274274
def load_state(self, state):
275275
"""load job_id from state"""
@@ -499,7 +499,12 @@ def user_env(self, env):
499499
return env
500500

501501
def get_env(self):
502-
"""Add user environment variables"""
502+
"""Add user environment variables.
503+
504+
Everything here should be passed to the user's job. If it is
505+
used to authenticate to the batch system commands as an admin,
506+
beware that the user will get them too.
507+
"""
503508
env = super().get_env()
504509
env = self.user_env(env)
505510
return env

0 commit comments

Comments
 (0)