mirror of
https://github.com/wassname/ray.git
synced 2026-06-29 05:34:49 +08:00
[autoscaler] Sometimes instances are restarted even when they don't need to be (#1385)
* fix hash * Update autoscaler.py
This commit is contained in:
committed by
Robert Nishihara
parent
c1e8f9477a
commit
77af2b5516
@@ -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)
|
||||
|
||||
|
||||
@@ -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...")
|
||||
|
||||
Reference in New Issue
Block a user