From d8642fe13e51614e8afdb804362168650843de63 Mon Sep 17 00:00:00 2001 From: Cary Goltermann Date: Wed, 7 Aug 2024 22:15:45 -0400 Subject: [PATCH] [GCP] Cluster info respects `use_internal_ips` (#3815) * Check provider_config.use_internal_ips * Update doc string * Use update when getting cached cluster feasible ips * Update sky/provision/common.py Co-authored-by: Zhanghao Wu --------- Co-authored-by: Zhanghao Wu --- sky/backends/cloud_vm_ray_backend.py | 4 +--- sky/provision/common.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sky/backends/cloud_vm_ray_backend.py b/sky/backends/cloud_vm_ray_backend.py index 10dae8a2c03..a5f559202a4 100644 --- a/sky/backends/cloud_vm_ray_backend.py +++ b/sky/backends/cloud_vm_ray_backend.py @@ -2248,9 +2248,7 @@ def update_cluster_ips( """ if cluster_info is not None: self.cached_cluster_info = cluster_info - use_internal_ips = self._use_internal_ips() - cluster_feasible_ips = self.cached_cluster_info.get_feasible_ips( - use_internal_ips) + cluster_feasible_ips = self.cached_cluster_info.get_feasible_ips() cluster_internal_ips = self.cached_cluster_info.get_feasible_ips( force_internal_ips=True) else: diff --git a/sky/provision/common.py b/sky/provision/common.py index a588fbe94e8..2284ce04ab8 100644 --- a/sky/provision/common.py +++ b/sky/provision/common.py @@ -204,8 +204,14 @@ def _get_ips(self, use_internal_ips: bool) -> List[str]: return ip_list def get_feasible_ips(self, force_internal_ips: bool = False) -> List[str]: - """Get external IPs if they exist, otherwise get internal ones.""" - return self._get_ips(not self.has_external_ips() or force_internal_ips) + """Get internal or external IPs depends on the settings.""" + if self.provider_config is not None: + use_internal_ips = self.provider_config.get('use_internal_ips', + False) + else: + use_internal_ips = False + return self._get_ips(use_internal_ips or not self.has_external_ips() or + force_internal_ips) def get_ssh_ports(self) -> List[int]: """Get the SSH port of all the instances."""