mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Only return unprivileged ports in get_random_port and fix nc argument bug
This commit is contained in:
parent
39e0703ae6
commit
62bc09adf3
@ -50,7 +50,7 @@ kube::util::wait_for_url() {
|
||||
|
||||
# returns a random port
|
||||
kube::util::get_random_port() {
|
||||
awk -v min=1 -v max=65535 'BEGIN{srand(); print int(min+rand()*(max-min+1))}'
|
||||
awk -v min=1024 -v max=65535 'BEGIN{srand(); print int(min+rand()*(max-min+1))}'
|
||||
}
|
||||
|
||||
# use netcat to check if the host($1):port($2) is free (return 0 means free, 1 means used)
|
||||
@ -65,7 +65,7 @@ kube::util::test_host_port_free() {
|
||||
return ${success}
|
||||
}
|
||||
|
||||
if [ ! $(nc -vz "${host} ${port}") ]; then
|
||||
if [ ! $(nc -vz "${host}" "${port}") ]; then
|
||||
kube::log::status "${host}:${port} is free, proceeding..."
|
||||
return ${success}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user