[autoscaler] Sometimes instances are restarted even when they don't need to be (#1385)

* fix hash

* Update autoscaler.py
This commit is contained in:
Eric Liang
2018-01-02 16:34:46 -08:00
committed by Robert Nishihara
parent c1e8f9477a
commit 77af2b5516
2 changed files with 5 additions and 3 deletions
+3 -2
View File
@@ -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)
+2 -1
View File
@@ -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...")