Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/config_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ System Partition Configuration
The Slurm-based backends unset all ``SBATCH_*`` environment variables before submitting a job.
This is done to avoid environment variables bypassing ReFrame's configuration.
For example, if the :attr:`~config.systems.partitions.access` options for a partition used ``-A foo`` and ``SBATCH_ACCOUNT=bar`` was set, then the environment variable would override the configuration, as ReFrame emits those (by default) in the submission script.
If this is not desired, environment variables can be explicitly whitelisted using the :attr:`~config.systems.partitions.sched_options.slurm_envvar_whitelist` option.

Job submission in ReFrame is controlled exclusively by the system partition's :attr:`~config.systems.partitions.access` options, the test job's :attr:`~reframe.core.schedulers.Job.options` and the :option:`-J` command-line option.

Expand Down Expand Up @@ -511,6 +512,18 @@ System Partition Configuration
.. versionadded:: 4.8


.. py:attribute:: systems.partitions.sched_options.slurm_envvar_whitelist

:required: No
:default: ``[]``

List of Slurm environment variables that will not be unset when submitting a job.

This option is relevant for the Slurm backends only.

.. versionadded:: 4.10


.. py:attribute:: systems.partitions.sched_options.slurm_job_cancel_reasons

:required: No
Expand Down
4 changes: 3 additions & 1 deletion reframe/core/schedulers/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def __init__(self):
'PLANNED',
'RESERVED'
}
self._envvar_whitelist = set(self.get_option('slurm_envvar_whitelist'))

# Define the base sacct and squeue commands to account for Slurm's
# multiple cluster mode if enabled
Expand Down Expand Up @@ -282,7 +283,8 @@ def sbatch(self, args):

with rt.temp_environment():
for var in [name for name in os.environ.keys()
if name.startswith('SBATCH_')]:
if name.startswith('SBATCH_') and
name not in self._envvar_whitelist]:
self.log(f'unsetting environment variable {var}',
logging.DEBUG)
del os.environ[var]
Expand Down
5 changes: 5 additions & 0 deletions reframe/schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
"type": "array",
"items": {"type": "string"}
},
"slurm_envvar_whitelist": {
"type": "array",
"items": {"type": "string"}
},
"slurm_job_cancel_reasons": {
"type": "array",
"items": {"type": "string"}
Expand Down Expand Up @@ -720,6 +724,7 @@
"systems*/sched_options/slurm_multi_cluster_mode": [],
"systems*/sched_options/ssh_hosts": [],
"systems*/sched_options/resubmit_on_errors": [],
"systems*/sched_options/slurm_envvar_whitelist": [],
"systems*/sched_options/slurm_job_cancel_reasons": ["ReqNodeNotAvail"],
"systems*/sched_options/slurm_pending_job_reason_poll_freq": 10,
"systems*/sched_options/unqualified_hostnames": false,
Expand Down
Loading