Repository: ray-project/ray

Issue:
IOCTL error in Autoscaler
<!--Please include [tune], [rllib], [autoscaler] etc. in the issue title if relevant-->

### What is the problem?
The following error message is printed repeatedly when using the autoscaler. It appears many times during `ray up ...`
```
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
```


*Ray version and other system information (Python version, TensorFlow version, OS):*

### Reproduction (REQUIRED)
Please provide a script that can be run to reproduce the issue. The script should have **no external library dependencies** (i.e., use fake or mock data / environments):

If we cannot run your script, we cannot fix your issue.

- [x] I have verified my script runs in a clean environment and reproduces the issue.
- [ ] I have verified the issue also occurs with the [latest wheels](https://docs.ray.io/en/latest/installation.html).



Discussion:

Resolving patch:
diff --git a/python/ray/autoscaler/commands.py b/python/ray/autoscaler/commands.py
--- a/python/ray/autoscaler/commands.py
+++ b/python/ray/autoscaler/commands.py
@@ -453,7 +453,6 @@ def _exec(updater, cmd, screen, tmux, port_forward=None, with_output=False):
             cmd = " ".join(cmd)
     return updater.cmd_runner.run(
         cmd,
-        allocate_tty=True,
         exit_on_fail=True,
         port_forward=port_forward,
         with_output=with_output)
diff --git a/python/ray/autoscaler/updater.py b/python/ray/autoscaler/updater.py
--- a/python/ray/autoscaler/updater.py
+++ b/python/ray/autoscaler/updater.py
@@ -47,7 +47,6 @@ def __init__(self, log_prefix, namespace, node_id, auth_config,
     def run(self,
             cmd=None,
             timeout=120,
-            allocate_tty=False,
             exit_on_fail=False,
             port_forward=None,
             with_output=False):
@@ -77,12 +76,12 @@ def run(self,
             raise Exception(exception_str)
         else:
             logger.info(self.log_prefix + "Running {}...".format(cmd))
-            final_cmd = self.kubectl + [
-                "exec",
-                "-it" if allocate_tty else "-i",
+            final_cmd = self.kubectl + ["exec", "-it"]
+            final_cmd += [
                 self.node_id,
                 "--",
-            ] + with_interactive(cmd)
+            ]
+            final_cmd += with_interactive(cmd)
             try:
                 if with_output:
                     return self.process_runner.check_output(
@@ -230,16 +229,13 @@ def set_ssh_ip_if_required(self):
     def run(self,
             cmd,
             timeout=120,
-            allocate_tty=False,
             exit_on_fail=False,
             port_forward=None,
             with_output=False):
 
         self.set_ssh_ip_if_required()
 
-        ssh = ["ssh"]
-        if allocate_tty:
-            ssh.append("-tt")
+        ssh = ["ssh", "-tt"]
 
         if port_forward:
             if not isinstance(port_forward, list):
@@ -259,7 +255,8 @@ def run(self,
         else:
             # We do this because `-o ControlMaster` causes the `-N` flag to
             # still create an interactive shell in some ssh versions.
-            final_cmd.append("while true; do sleep 86400; done")
+            final_cmd.append(quote("while true; do sleep 86400; done"))
+
         try:
             if with_output:
                 return self.process_runner.check_output(final_cmd)


Test patch: