Skip to content

Commit b2b55b0

Browse files
committed
Reflect comments
1 parent 65236ea commit b2b55b0

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

docs/software/container-engine/known-issue.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,12 @@ Defining a mount related to `/users` in the EDF should only be done when there i
5656
[](){#ref-ce-why-no-sbatch-env}
5757
## Why `--environment` as `#SBATCH` is discouraged
5858

59-
Due to how Slurm works, when using `--environment` as an `#SBATCH` option, the entire contents of the SBATCH script is executed within a container created by the EDF file.
60-
This can lead to subtle and hard-to-diagnose failures, some of which are described below.
59+
The use of `--environment` as `#SBATCH` is known to cause **unexpected behaviors** and is exclusively reserved for highly customized workflows. This is because `--environment` as `#SBATCH` puts the entire SBATCH script in a container from the EDF file. The following are a few known associated issues.
6160

62-
- **Slurm availability in the container**: In some cases, CE does not inject essential Slurm components in containers, which result in crashes on basic Slurm operations (e.g., `srun`) inside the SBATCH script. Even if they were injected, it's not guaranteed to cover the complete feature set of Slurm.
61+
- **Slurm availability in a container**: Either Slurm components are not completely injected inside a container, or injected Slurm components do not function properly.
6362

64-
- **The execution context is not the host system**: Since the entire SBATCH script runs inside a container (shaped with EDF), all commands in the script are affected by the environment defined by EDF. This primarily includes filesystem mounts, where any directories not explicitly mounted in EDF are invisible to all commands inside the SBATCH script.
63+
- **Non-host execution context**: Since the SBATCH script runs inside a container, most host resources are inaccessible by default unless EDF explicitly exposes them. Affected resources include: filesystems, devices, system resources, container hooks, etc.
6564

66-
- **Nested use of `--environment`**: `--environment` in the SBATCH script _and_ for a `srun` command results in entering the EDF environment twice, causing unexpected errors due to double-entering containers.
65+
- **Nested use of `--environment`**: running `srun --environment` in `#SBATCH --environment` results in double-entering EDF containers, causing unexpected errors in the underlying container runtime.
6766

68-
For these reasons, we encourage using `--environment` for each `srun` as shown below.
69-
70-
```bash
71-
#!/bin/bash
72-
#SBATCH --cpus-per-task=4
73-
...
74-
srun --environment=my_edf echo 'this'
75-
...
76-
srun --environment=my_edf echo 'that'
77-
...
78-
```
79-
80-
As the use of `--environment` as an `#SBATCH` option is reserved for highly customized workflows, users should have a high level of proficiency and a full understanding of the risk to encounter cryptic behaviors. Should users encounter a problem while using `--environment` as `#SBATCH`, it's recommended to move `--environment` from `#SBATCH` to each `srun` and see if the problem disappears.
67+
To avoid any unexpected confusion, users are advised **not** to use `--environment` as `#SBATCH`. If users encounter a problem while using this, it's recommended to move `--environment` from `#SBATCH` to each `srun` and see if the problem disappears.

docs/software/container-engine/run.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,25 @@ Use `--environment` with the Slurm command (e.g., `srun` or `salloc`):
3434
#SBATCH --job-name=edf-example
3535
#SBATCH --time=00:01:00
3636
...
37-
38-
# Run job step
3937
srun --environment=ubuntu cat /etc/os-release
4038
```
4139

40+
Multiple Slurm commands may have different EDF environments; this is useful when a single environment is not feasible due to the compatibility issues between programs.
41+
42+
!!! example "`srun`s with different EDFs"
43+
```bash
44+
#!/bin/bash
45+
#SBATCH --job-name=edf-example
46+
#SBATCH --time=00:01:00
47+
...
48+
srun --environment=env1 ... # (1)!
49+
...
50+
srun --environment=env2 ... # (2)!
51+
```
52+
53+
1. Assuming `env1.toml` is at `EDF_PATH`. See [EDF search path][ref-ce-edf-search-path] below.
54+
2. Assuming `env2.toml` is at `EDF_PATH`. See [EDF search path][ref-ce-edf-search-path] below.
55+
4256
Specifying the `--environment` option with an `#SBATCH` option is **experimental**.
4357
Such usage is discouraged as it may result in unexpected behaviors.
4458

0 commit comments

Comments
 (0)