Skip to content

Commit

Permalink
Fix race condition connecting to docker ondemand_cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
dongreenberg committed Jul 2, 2024
1 parent 221f3b6 commit d150555
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions runhouse/resources/hardware/sky_ssh_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,17 @@ def tunnel(self, local_port, remote_port):
ssh_mode=SshMode.NON_INTERACTIVE, port_forward=[(local_port, remote_port)]
)
command = " ".join(base_cmd)
logger.debug(f"Running forwarding command: {command}")
logger.info(f"Running forwarding command: {command}")
proc = subprocess.Popen(
shlex.split(command),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
# Wait for the ssh connection to start
time.sleep(1)
# Wait until tunnel is formed, i.e. first line is printed from ssh server ("Welcome to Ubuntu...")
# Without this we'll get connection errors from the HTTPClient attempting to connect before
# the tunnel is fully formed.
proc.stdout.readline()

# Set the tunnel process and ports to be cleaned up later
self.tunnel_proc = proc
Expand Down

0 comments on commit d150555

Please sign in to comment.