Skip to content

Commit

Permalink
move ports delta calculation into _update_after_cluster_provisioned
Browse files Browse the repository at this point in the history
  • Loading branch information
cblmemo committed Sep 17, 2023
1 parent 4bc2fba commit 3b33aac
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions sky/backends/cloud_vm_ray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2857,18 +2857,9 @@ def _get_zone(runner):
# launched in different zones (legacy clusters before
# #1700), leave the zone field of handle.launched_resources
# to None.
prev_ports = None
if to_provision_config.prev_handle is not None:
prev_ports = (
to_provision_config.prev_handle.launched_resources.ports)
current_ports = handle.launched_resources.ports
open_new_ports = bool(
resources_utils.port_ranges_to_set(current_ports) -
resources_utils.port_ranges_to_set(prev_ports))
self._update_after_cluster_provisioned(handle, task,
prev_cluster_status, ip_list,
ssh_port_list,
open_new_ports, lock_path)
self._update_after_cluster_provisioned(
handle, to_provision_config.prev_handle, task,
prev_cluster_status, ip_list, ssh_port_list, lock_path)
return handle

def _open_ports(self, handle: CloudVmRayResourceHandle) -> None:
Expand All @@ -2882,9 +2873,10 @@ def _open_ports(self, handle: CloudVmRayResourceHandle) -> None:
provider_config)

def _update_after_cluster_provisioned(
self, handle: CloudVmRayResourceHandle, task: task_lib.Task,
self, handle: CloudVmRayResourceHandle,
prev_handle: CloudVmRayResourceHandle, task: task_lib.Task,
prev_cluster_status: Optional[status_lib.ClusterStatus],
ip_list: List[str], ssh_port_list: List[int], open_new_ports: bool,
ip_list: List[str], ssh_port_list: List[int],
lock_path: str) -> None:
usage_lib.messages.usage.update_cluster_resources(
handle.launched_nodes, handle.launched_resources)
Expand Down Expand Up @@ -2930,6 +2922,13 @@ def _update_after_cluster_provisioned(
'Failed to set previously in-progress jobs to FAILED',
stdout + stderr)

prev_ports = None
if prev_handle is not None:
prev_ports = prev_handle.launched_resources.ports
current_ports = handle.launched_resources.ports
open_new_ports = bool(
resources_utils.port_ranges_to_set(current_ports) -
resources_utils.port_ranges_to_set(prev_ports))
if open_new_ports:
with rich_utils.safe_status(
'[bold cyan]Launching - Opening new ports'):
Expand Down

0 comments on commit 3b33aac

Please sign in to comment.