From 77af2b5516515ec6cb04a7c601deb52e72c7da60 Mon Sep 17 00:00:00 2001 From: Eric Liang Date: Tue, 2 Jan 2018 16:34:46 -0800 Subject: [PATCH] [autoscaler] Sometimes instances are restarted even when they don't need to be (#1385) * fix hash * Update autoscaler.py --- python/ray/autoscaler/autoscaler.py | 5 +++-- python/ray/autoscaler/commands.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/ray/autoscaler/autoscaler.py b/python/ray/autoscaler/autoscaler.py index 13f97e0ea..95e4b0bf2 100644 --- a/python/ray/autoscaler/autoscaler.py +++ b/python/ray/autoscaler/autoscaler.py @@ -493,7 +493,8 @@ def with_head_node_ip(cmds): def hash_launch_conf(node_conf, auth): hasher = hashlib.sha1() - hasher.update(json.dumps([node_conf, auth]).encode("utf-8")) + hasher.update( + json.dumps([node_conf, auth], sort_keys=True).encode("utf-8")) return hasher.hexdigest() @@ -516,7 +517,7 @@ def hash_runtime_conf(file_mounts, extra_objs): hasher.update(f.read().encode("utf-8")) hasher.update(json.dumps(sorted(file_mounts.items())).encode("utf-8")) - hasher.update(json.dumps(extra_objs).encode("utf-8")) + hasher.update(json.dumps(extra_objs, sort_keys=True).encode("utf-8")) for local_path in sorted(file_mounts.values()): add_content_hashes(local_path) diff --git a/python/ray/autoscaler/commands.py b/python/ray/autoscaler/commands.py index 28aa59042..e283eb970 100644 --- a/python/ray/autoscaler/commands.py +++ b/python/ray/autoscaler/commands.py @@ -80,12 +80,13 @@ def get_or_create_head_node(config, no_restart): if not head_node: confirm("This will create a new cluster") elif not no_restart: - confirm("This will restart your cluster") + confirm("This will restart cluster services") launch_hash = hash_launch_conf(config["head_node"], config["auth"]) if head_node is None or provider.node_tags(head_node).get( TAG_RAY_LAUNCH_CONFIG) != launch_hash: if head_node is not None: + confirm("Head node config out-of-date. It will be terminated") print("Terminating outdated head node {}".format(head_node)) provider.terminate_node(head_node) print("Launching new head node...")