Skip to content

Commit 915eb61

Browse files
committed
Pass all JULIA_* environment variables by default in the SSHManager
It's otherwise very annoying and error-prone to set these with every call to `addprocs()`.
1 parent 4277e77 commit 915eb61

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

docs/src/_changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ This documents notable changes in DistributedNext.jl. The format is based on
2020
the project of a remote worker ([#2]).
2121
- Workers will now attempt to pick the fastest available interface to
2222
communicate over ([#9]).
23+
- The `SSHManager` now passes all `JULIA_*` environment variables by default to
24+
the workers, instead of only `JULIA_WORKER_TIMEOUT` ([#9]).

src/managers.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ addprocs([
138138
139139
* `env`: provide an array of string pairs such as
140140
`env=["JULIA_DEPOT_PATH"=>"/depot"]` to request that environment variables
141-
are set on the remote machine. By default only the environment variable
142-
`JULIA_WORKER_TIMEOUT` is passed automatically from the local to the remote
143-
environment.
141+
are set on the remote machine. By default all `JULIA_*` environment variables
142+
are passed automatically from the local to the remote environment.
144143
145144
* `cmdline_cookie`: pass the authentication cookie via the `--worker` commandline
146145
option. The (more secure) default behaviour of passing the cookie via ssh stdio
@@ -294,8 +293,9 @@ function launch_on_machine(manager::SSHManager, machine::AbstractString, cnt, pa
294293
# Build up the ssh command
295294

296295
# pass on some environment variables by default
297-
for var in ["JULIA_WORKER_TIMEOUT"]
298-
if !haskey(env, var) && haskey(ENV, var)
296+
julia_vars = filter(startswith("JULIA_"), keys(ENV))
297+
for var in julia_vars
298+
if !haskey(env, var)
299299
env[var] = ENV[var]
300300
end
301301
end

test/sshmanager.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ end
7171
test_n_remove_pids(new_pids)
7272
@test :ok == timedwait(()->!issocket(controlpath), 10.0; pollint=0.5)
7373

74+
print("\nTest SSH addprocs() passing environment variables\n")
75+
withenv("JULIA_FOO" => "foo") do
76+
new_pids = addprocs_with_testenv(["localhost"]; sshflags)
77+
@test remotecall_fetch(() -> ENV["JULIA_FOO"], only(new_pids)) == "foo"
78+
test_n_remove_pids(new_pids)
79+
end
80+
7481
print("\nAll supported formats for hostname\n")
7582
h1 = "localhost"
7683
user = ENV["USER"]

0 commit comments

Comments
 (0)