|
9 | 9 | a cluster is first created. This then makes it possible for us to support |
10 | 10 | changing the proxy command without changing the launch hash in the future. |
11 | 11 |
|
12 | | -2. The _should_create_new_head() function inside Ray autoscaler to avoid the ray up |
| 12 | +2. The _should_create_new_head() function inside Ray autoscaler to avoid the ray up |
13 | 13 | checking the launch hash when creating the head node. |
14 | 14 |
|
15 | 15 | Reasons: |
|
26 | 26 | the logic for considering what worker nodes to restart/"reuse" is in node_provider.py's |
27 | 27 | create_node(), the same code for deciding what head node to restart/"reuse". |
28 | 28 | """ |
29 | | -import hashlib |
30 | | -import json |
31 | | -import os |
32 | | - |
33 | 29 | from ray.autoscaler import sdk |
| 30 | +from ray.autoscaler._private import util as ray_autoscaler_util |
34 | 31 |
|
35 | 32 |
|
36 | | -# Ref: https://github.com/ray-project/ray/blob/releases/2.4.0/python/ray/autoscaler/_private/util.py#L396-L408 |
| 33 | +# Delegate to Ray's own implementation rather than copying it: `ray up` runs |
| 34 | +# against whatever Ray the client has installed, and Ray has already changed |
| 35 | +# this digest once (sha1/hexdigest -> sha256/base32hex). A copy would silently |
| 36 | +# disagree with the hash Ray's own node_launcher writes for worker nodes. |
37 | 37 | def monkey_patch_hash_launch_conf(node_conf, auth): |
38 | | - hasher = hashlib.sha1() |
39 | | - # For hashing, we replace the path to the key with the key |
40 | | - # itself. This is to make sure the hashes are the same even if keys |
41 | | - # live at different locations on different machines. |
42 | | - full_auth = auth.copy() |
43 | | - full_auth.pop('ssh_proxy_command', None) # NOTE: skypilot changes. |
44 | | - for key_type in ['ssh_private_key', 'ssh_public_key']: |
45 | | - if key_type in auth: |
46 | | - with open(os.path.expanduser(auth[key_type]), |
47 | | - encoding='utf-8') as key: |
48 | | - full_auth[key_type] = key.read() |
49 | | - hasher.update( |
50 | | - json.dumps([node_conf, full_auth], sort_keys=True).encode('utf-8')) |
51 | | - return hasher.hexdigest() |
| 38 | + # NOTE: skypilot change -- exclude ssh_proxy_command from the hash. |
| 39 | + auth = {k: v for k, v in auth.items() if k != 'ssh_proxy_command'} |
| 40 | + return ray_autoscaler_util.hash_launch_conf(node_conf, auth) |
52 | 41 |
|
53 | 42 |
|
54 | | -# Ref: https://github.com/ray-project/ray/blob/releases/2.4.0/python/ray/autoscaler/_private/commands.py#L854-L912 |
| 43 | +# Ref: https://github.com/ray-project/ray/blob/ray-2.56.1/python/ray/autoscaler/_private/commands.py#L999-L1057 |
55 | 44 | def monkey_patch_should_create_new_head( |
56 | 45 | head_node_id, |
57 | 46 | new_launch_hash, |
|
0 commit comments