Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[autoscaler v2] add test for node provider #35593

Merged
merged 29 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update
  • Loading branch information
scv119 committed May 22, 2023
commit 3f411e285d88b9ed16bfa18b35441313d9a940f9
8 changes: 6 additions & 2 deletions python/ray/autoscaler/_private/node_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def __init__(

def launch_node(self, config: Dict[str, Any], count: int, node_type: str):
scv119 marked this conversation as resolved.
Show resolved Hide resolved
self.log("Got {} nodes to launch.".format(count))
self._launch_node(config, count, node_type)
created_nodes = self._launch_node(config, count, node_type)
self.pending.dec(node_type, count)
return created_nodes

def _launch_node(self, config: Dict[str, Any], count: int, node_type: str):
scv119 marked this conversation as resolved.
Show resolved Hide resolved
if self.node_types:
Expand Down Expand Up @@ -100,8 +101,9 @@ def _launch_node(self, config: Dict[str, Any], count: int, node_type: str):

error_msg = None
full_exception = None
created_nodes = {}
try:
self.provider.create_node_with_resources(
created_nodes = self.provider.create_node_with_resources(
rickyyx marked this conversation as resolved.
Show resolved Hide resolved
node_config, node_tags, count, resources
)
except NodeLaunchException as node_launch_exception:
Expand Down Expand Up @@ -158,6 +160,8 @@ def _launch_node(self, config: Dict[str, Any], count: int, node_type: str):
if full_exception is not None:
self.log(full_exception)

return created_nodes

def log(self, statement):
# launcher_class is "BaseNodeLauncher", or "NodeLauncher" if called
# from that subclass.
Expand Down
8 changes: 4 additions & 4 deletions python/ray/autoscaler/v2/instance_manager/node_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ def _filter_instances(

@override
def create_nodes(self, instance_type: InstanceType, count: int) -> List[Instance]:
result = self._node_launcher.launch_node(
created_nodes = self._node_launcher.launch_node(
self._config.get_raw_config_mutable(),
count,
instance_type.name,
)
# TODO: we should handle failures where the instance type is
# not available
if result:
if created_nodes:
return [
self._get_instance(cloud_instance_id)
for cloud_instance_id in result.keys()
for cloud_instance_id in created_nodes.keys()
rickyyx marked this conversation as resolved.
Show resolved Hide resolved
]
return []

Expand All @@ -107,7 +107,7 @@ def is_readonly(self) -> bool:
@override
def get_non_terminated_nodes(self):
clould_instance_ids = self._provider.non_terminated_nodes()
return self.get_nodes_by_id(clould_instance_ids)
return self.get_nodes_by_cloud_id(clould_instance_ids)

@override
def get_nodes_by_cloud_id(
Expand Down