Revert "[autoscaler/k8s] Use ray node's HOME in Kubernetes command runner. (#12417)" (#12607)

This reverts commit f669830de6.
This commit is contained in:
Eric Liang 2020-12-03 12:57:59 -08:00 committed by GitHub
parent 1f7a4806ff
commit 36e46ed923
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 22 deletions

View file

@ -47,7 +47,7 @@ class StandardAutoscaler:
There are two ways to start an autoscaling cluster: manually by running
`ray start --head --autoscaling-config=/path/to/config.yaml` on a
instance that has permission to launch other instances, or you can also use
`ray up /path/to/config.yaml` from your laptop, which will
`ray create_or_update /path/to/config.yaml` from your laptop, which will
configure the right AWS/Cloud roles automatically.
StandardAutoscaler's `update` method is periodically called by `monitor.py`

View file

@ -29,6 +29,8 @@ from ray.autoscaler._private.subprocess_output_util import (
from ray.autoscaler._private.cli_logger import cli_logger, cf
from ray.util.debug import log_once
from ray.autoscaler._private.constants import RAY_HOME
logger = logging.getLogger(__name__)
# How long to wait for a node to start, in seconds
@ -112,7 +114,6 @@ class KubernetesCommandRunner(CommandRunnerInterface):
self.node_id = str(node_id)
self.namespace = namespace
self.kubectl = ["kubectl", "-n", self.namespace]
self._home = None
def run(
self,
@ -194,7 +195,7 @@ class KubernetesCommandRunner(CommandRunnerInterface):
logger.warning("'rsync_filter' detected but is currently "
"unsupported for k8s.")
if target.startswith("~"):
target = self.home + target[1:]
target = RAY_HOME + target[1:]
try:
flags = "-aqz" if is_rsync_silent() else "-avz"
@ -210,7 +211,7 @@ class KubernetesCommandRunner(CommandRunnerInterface):
"rsync failed: '{}'. Falling back to 'kubectl cp'".format(e),
UserWarning)
if target.startswith("~"):
target = self.home + target[1:]
target = RAY_HOME + target[1:]
self.process_runner.check_call(self.kubectl + [
"cp", source, "{}/{}:{}".format(self.namespace, self.node_id,
@ -218,8 +219,8 @@ class KubernetesCommandRunner(CommandRunnerInterface):
])
def run_rsync_down(self, source, target, options=None):
if source.startswith("~"):
source = self.home + source[1:]
if target.startswith("~"):
target = RAY_HOME + target[1:]
try:
flags = "-aqz" if is_rsync_silent() else "-avz"
@ -235,7 +236,7 @@ class KubernetesCommandRunner(CommandRunnerInterface):
"rsync failed: '{}'. Falling back to 'kubectl cp'".format(e),
UserWarning)
if target.startswith("~"):
target = self.home + target[1:]
target = RAY_HOME + target[1:]
self.process_runner.check_call(self.kubectl + [
"cp", "{}/{}:{}".format(self.namespace, self.node_id, source),
@ -243,22 +244,9 @@ class KubernetesCommandRunner(CommandRunnerInterface):
])
def remote_shell_command_str(self):
return "{} exec -it {} -- bash".format(" ".join(self.kubectl),
return "{} exec -it {} bash".format(" ".join(self.kubectl),
self.node_id)
@property
def home(self):
# TODO (Dmitri): Think about how to use the node's HOME variable
# without making an extra kubectl exec call.
if self._home is None:
cmd = self.kubectl + [
"exec", "-it", self.node_id, "--", "printenv", "HOME"
]
joined_cmd = " ".join(cmd)
raw_out = self.process_runner.check_output(joined_cmd, shell=True)
self._home = raw_out.decode().strip("\n\r")
return self._home
class SSHOptions:
def __init__(self, ssh_key, control_path=None, **kwargs):