Steps to reproduce
Perhaps there is an easier way to reproduce it, but this is the actual setup in which the issue was discovered:
- Configure a Slurm cluster as a
dstack backend. Important: nodes must use a distro where /bin/sh is Bash (readlink -f /bin/sh → /usr/bin/bash). We deployed a cluster using GCP's cluster-toolkit, which uses Rocky Linux.
- Export a Bash function function via profile, e.g., add to
~/.bash_profile:
say_hi() { echo hi; }
export -f say_hi
The image used by GCP's cluster-toolkit has Lmod preinstalled, which exports its functions.
- Submit a run with
image based on a distro where /bin/sh is Bash, e.g., Fedora:
type: task
image: fedora
commands:
- printenv | grep BASH_FUNC_
- SSH into the run
grep BASH_FUNC_ /dstack/profile
The reason why we need a distro with sh→bash symlink is that (d)ash (used by, e.g., Debian/Ubuntu) removes invalid variables (BASH_FUNC_<name>%% format with % is intentionally used by Bash; such a name is not a valid shell identifier) while Bash in POSIX mode bypass them to child processes (and, apparently, even source them). With the Slurm backend, we have 3 sh calls in the chain:
Actual behaviour
Run commands output:
BASH_FUNC_ml%%=() { eval $($LMOD_DIR/ml_cmd "$@")
BASH_FUNC_which%%=() { ( alias;
BASH_FUNC_say_hi%%=() { echo hi
BASH_FUNC_module%%=() { eval $($LMOD_CMD bash "$@") && eval $(${LMOD_SETTARG_CMD:-:} -s sh)
ssh run-name output:
Warning: Permanently added '[slurm-mainnodeset-0]:10022' (ED25519) to the list of known hosts.
-bash: export: `BASH_FUNC_which%%=() { ( alias;
eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
}': not a valid identifier
-bash: export: `BASH_FUNC_ml%%=() { eval $($LMOD_DIR/ml_cmd "$@")
}': not a valid identifier
-bash: export: `BASH_FUNC_say_hi%%=() { echo hi
}': not a valid identifier
-bash: export: `BASH_FUNC_module%%=() { eval $($LMOD_CMD bash "$@") && eval $(${LMOD_SETTARG_CMD:-:} -s sh)
}': not a valid identifier
grep BASH_FUNC_ /dstack/profile:
export BASH_FUNC_which%%='() { ( alias;
export BASH_FUNC_ml%%='() { eval $($LMOD_DIR/ml_cmd "$@")
export BASH_FUNC_say_hi%%='() { echo hi
export BASH_FUNC_module%%='() { eval $($LMOD_CMD bash "$@") && eval $(${LMOD_SETTARG_CMD:-:} -s sh)
Expected behaviour
No response
dstack version
0.21.1
Server logs
Additional information
No response
Steps to reproduce
Perhaps there is an easier way to reproduce it, but this is the actual setup in which the issue was discovered:
dstackbackend. Important: nodes must use a distro where/bin/shis Bash (readlink -f /bin/sh→/usr/bin/bash). We deployed a cluster using GCP's cluster-toolkit, which uses Rocky Linux.~/.bash_profile:imagebased on a distro where/bin/shis Bash, e.g., Fedora:grep BASH_FUNC_ /dstack/profileThe reason why we need a distro with
sh→bashsymlink is that (d)ash (used by, e.g., Debian/Ubuntu) removes invalid variables (BASH_FUNC_<name>%%format with%is intentionally used by Bash; such a name is not a valid shell identifier) while Bash in POSIX mode bypass them to child processes (and, apparently, even source them). With the Slurm backend, we have 3 sh calls in the chain:srun sh -c ...JobSpec.commandsgenerated fromshell+commandswhereshelldefaults to/bin/shwhenimageis setActual behaviour
Run
commandsoutput:ssh run-nameoutput:grep BASH_FUNC_ /dstack/profile:Expected behaviour
No response
dstack version
0.21.1
Server logs
Additional information
No response