Skip to content

Commit

Permalink
[Lambda] Fix termination for lambda (#3410)
Browse files Browse the repository at this point in the history
* Fix termination for lambda

* format
  • Loading branch information
Michaelvll authored Apr 3, 2024
1 parent 76e1e4c commit ffc8618
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions sky/clouds/lambda_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ def query_status(cls, name: str, tag_filters: Dict[str, str],
'booting': status_lib.ClusterStatus.INIT,
'active': status_lib.ClusterStatus.UP,
'unhealthy': status_lib.ClusterStatus.INIT,
'terminating': None,
'terminated': None,
}
# TODO(ewzeng): filter by hash_filter_string to be safe
Expand Down
6 changes: 5 additions & 1 deletion sky/skylet/providers/lambda_cloud/node_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _match_tags(vm: Dict[str, Any]):
def _get_internal_ip(node: Dict[str, Any]):
# TODO(ewzeng): cache internal ips in metadata file to reduce
# ssh overhead.
if node['external_ip'] is None:
if node['external_ip'] is None or node['status'] != 'active':
node['internal_ip'] = None
return
runner = command_runner.SSHCommandRunner(node['external_ip'],
Expand All @@ -172,6 +172,10 @@ def _get_internal_ip(node: Dict[str, Any]):
self.metadata.refresh([node['id'] for node in vms])
self._guess_and_add_missing_tags(vms)
nodes = [_extract_metadata(vm) for vm in filter(_match_tags, vms)]
nodes = [
node for node in nodes
if node['status'] not in ['terminating', 'terminated']
]
subprocess_utils.run_in_parallel(_get_internal_ip, nodes)
self.cached_nodes = {node['id']: node for node in nodes}
return self.cached_nodes
Expand Down

0 comments on commit ffc8618

Please sign in to comment.