Skip to content

Commit

Permalink
do not generate new port in host network
Browse files Browse the repository at this point in the history
  • Loading branch information
xudifsd committed Dec 31, 2019
1 parent fa0b2f2 commit fb4251c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/docker-images/init-container/runtime/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ def main(args):
pod_name = get_pod_name()
job_name = get_job_name()
ip = get_pod_ip()
ssh_port = find_free_port()

if os.environ.get("DLWS_HOST_NETWORK") == "enable":
ssh_port = find_free_port()
else:
ssh_port = 22

ps_num = get_ps_number()
worker_num = get_worker_number()
expected_num = ps_num + worker_num
Expand Down
11 changes: 3 additions & 8 deletions src/init-scripts/setup_sshd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ function retry {
}

function setup_sshd {
# if "DLWS_HOST_NETWORK" enabled, randomly generate port in range: 40000-49999
if [ "$DLWS_HOST_NETWORK" = "enable" ];
then
SSH_PORT=$DLWS_SD_SELF_SSH_PORT
sed -i -E "s/^#?Port 22/Port ${SSH_PORT}/" /etc/ssh/sshd_config || exit 1
else
SSH_PORT=22
fi
SSH_PORT=$DLWS_SD_SELF_SSH_PORT
sed -i -E "s/^#?Port 22/Port ${SSH_PORT}/" /etc/ssh/sshd_config || exit 1

echo "${SSH_PORT}" > ${PROC_DIR}/SSH_PORT
echo "${POD_IP}" > ${PROC_DIR}/POD_IP

Expand Down

0 comments on commit fb4251c

Please sign in to comment.