Skip to content

Commit

Permalink
[GCP] Cluster info respects use_internal_ips (#3815)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Zhanghao Wu <[email protected]>
  • Loading branch information
Ultramann and Michaelvll authored Aug 8, 2024
1 parent 51f1f78 commit d8642fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 1 addition & 3 deletions sky/backends/cloud_vm_ray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions sky/provision/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit d8642fe

Please sign in to comment.