Skip to content

Commit

Permalink
document the allowed ports
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi committed Jun 27, 2024
1 parent 00f09f8 commit 29b6ea2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/jobsubmission.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1034,10 +1034,10 @@ struct WorkloadConfig
),
)
end
if !isnothing(expose) && !_is_valid_port_range(expose)
if !isnothing(expose) && !_is_valid_port(expose)
Base.throw(
ArgumentError(
"Invalid port value for expose: '$(expose)', must be >= 1 & <= 1 65535"
"Invalid port value for expose: '$(expose)', must be in 1025:9008, 9010:23399, 23500:32767"
),
)
end
Expand All @@ -1054,8 +1054,10 @@ struct WorkloadConfig
end
end

# TODO: need to define the valid port range
_is_valid_port_range(port::Integer) = 1 <= port <= 65535
_is_valid_port(port::Integer) = any(
portrange -> in(port, portrange),
(1025:9008, 9010:23399, 23500:32767),
)

_is_gpu_job(workload::WorkloadConfig) = workload.compute.node.hasGPU

Expand Down Expand Up @@ -1128,8 +1130,10 @@ of the job.
with. If a string is passed, it must parse as a valid UUID. Passing `nothing` is equivalent to omitting the
argument.
* `expose :: Union{Integer, Nothing}`: if set to an integer in the valid port range (i.e. anything other than
`9009`, which is reserved), that port will be exposed over HTTPS, allowing for (authenticated) HTTP calls.
* `expose :: Union{Integer, Nothing}`: if set to an integer in the valid port ranges, that port will be exposed
over HTTPS, allowing for (authenticated) HTTP request to be performed against the job, as long as the job
binds an HTTP server to that port. The allowed port ranges are `1025-9008``, `9010-23399`, `23500-32767`
(in other words, `<= 1024`, `9009`, `23400-23499`, and `>= 32768` can not be used).
[See the relevant manual section for more information.](@ref jobs-batch-expose-port)
**General arguments.**
Expand Down
2 changes: 1 addition & 1 deletion test/jobs-exposed-port-live.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ end
# set env environment variable.
job, _ = submit_test_job(
JuliaHub.appbundle(JOBENV_EXPOSED_PORT, "server.jl");
expose=23456, env=Dict("TEST_INPUT" => "foobar"),
expose=30000, env=Dict("TEST_INPUT" => "foobar"),
alias="exposed-port-no-image", auth,
)
try
Expand Down
10 changes: 9 additions & 1 deletion test/jobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -925,11 +925,19 @@ JuliaHub._OPTION_LoggingMode[] = JuliaHub._LoggingMode.NOKAFKA
let jc = JuliaHub.submit_job(JuliaHub.script""; dryrun=true)
@test jc.exposed_port === nothing
end
@testset "port $port" for port in (1, 80, 443, 8080, 65_535)
@testset "port $port" for port in (1025, 8080, 9008, 9010, 18000, 24_399, 23_500, 31_767)
jc = JuliaHub.submit_job(JuliaHub.script""; expose=port, dryrun=true)
@test jc.exposed_port == port
end
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=0)
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=80)
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=443)
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=1024)
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=9009)
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=24_400)
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=24_499)
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=31_768)
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=40_000)
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=-200)
@test_throws ArgumentError JuliaHub.submit_job(JuliaHub.script"", expose=65_535 + 1)
end
Expand Down

0 comments on commit 29b6ea2

Please sign in to comment.