diff --git a/python/ray/autoscaler/command_runner.py b/python/ray/autoscaler/command_runner.py index a7e1d2c01..97e133023 100644 --- a/python/ray/autoscaler/command_runner.py +++ b/python/ray/autoscaler/command_runner.py @@ -431,7 +431,6 @@ class SSHCommandRunner(CommandRunnerInterface): If `exit_on_fail` is `True`, the process will exit if the command fails (exits with a code other than 0). """ - try: # For now, if the output is needed we just skip the new logic. # In the future we could update the new logic to support @@ -520,7 +519,7 @@ class SSHCommandRunner(CommandRunnerInterface): else: # We do this because `-o ControlMaster` causes the `-N` flag to # still create an interactive shell in some ssh versions. - final_cmd.append(quote("while true; do sleep 86400; done")) + final_cmd.append("while true; do sleep 86400; done") cli_logger.verbose("Running `{}`", cf.bold(cmd)) with cli_logger.indented(): diff --git a/python/ray/scripts/scripts.py b/python/ray/scripts/scripts.py index 8dc524d23..7d05e52c8 100644 --- a/python/ray/scripts/scripts.py +++ b/python/ray/scripts/scripts.py @@ -129,34 +129,28 @@ def dashboard(cluster_config_file, cluster_name, port, remote_port): """Port-forward a Ray cluster's dashboard to the local machine.""" # Sleeping in a loop is preferable to `sleep infinity` because the latter # only works on linux. - if port: - dashboard_port = port - else: - dashboard_port = remote_port - - port_taken = True - # Find the first open port sequentially from `remote_port`. - while port_taken: - try: - port_forward = [ - (dashboard_port, remote_port), - ] - click.echo(("Attempting to establish dashboard locally at" - " localhost:{} connected to" - " remote port {}").format(dashboard_port, remote_port)) - # We want to probe with a no-op that returns quickly to avoid - # exceptions caused by network errors. - exec_cluster( - cluster_config_file, - override_cluster_name=cluster_name, - port_forward=port_forward) - port_taken = False - except Exception: - click.echo("Failed to forward dashboard, trying a new port...") - port_taken = True - dashboard_port += 1 - pass + try: + port_forward = [ + (port, remote_port), + ] + click.echo("Attempting to establish dashboard locally at" + " localhost:{} connected to" + " remote port {}".format(port, remote_port)) + # We want to probe with a no-op that returns quickly to avoid + # exceptions caused by network errors. + exec_cluster( + cluster_config_file, + override_cluster_name=cluster_name, + port_forward=port_forward) + click.echo("Successfully established connection.") + except Exception as e: + raise click.ClickException( + "Failed to forward dashboard from remote port {1} to local port " + "{0}. There are a couple possibilities: \n 1. The remote port is " + "incorrectly specified \n 2. The local port {0} is already in " + "use.\n The exception is: {2}".format(port, remote_port, e)) \ + from None @cli.command()