Skip to content

[core][autoscaler][v1] prune IPs from the LoadMetrics after terminating nodes #52409

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 12 additions & 12 deletions python/ray/autoscaler/_private/autoscaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,18 +403,6 @@ def _update(self):
# This will accumulate the nodes we need to terminate.
self.nodes_to_terminate = []

# Update running nodes gauge
num_workers = len(self.non_terminated_nodes.worker_ids)
self.prom_metrics.running_workers.set(num_workers)

# Remove from LoadMetrics the ips unknown to the NodeProvider.
self.load_metrics.prune_active_ips(
active_ips=[
self.provider.internal_ip(node_id)
for node_id in self.non_terminated_nodes.all_node_ids
]
)

# Update status strings
if AUTOSCALER_STATUS_LOG:
logger.info(self.info_string())
Expand All @@ -437,6 +425,18 @@ def _update(self):
self.attempt_to_recover_unhealthy_nodes(now)
self.set_prometheus_updater_data()

# Update running nodes gauge
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: L406 - L426 update the list of alive nodes (i.e. non_terminated_nodes). This PR uses the updated list to update load metrics.

num_workers = len(self.non_terminated_nodes.worker_ids)
self.prom_metrics.running_workers.set(num_workers)

# Remove IPs from LoadMetrics that are not known to the NodeProvider.
self.load_metrics.prune_active_ips(
active_ips=[
self.provider.internal_ip(node_id)
for node_id in self.non_terminated_nodes.all_node_ids
]
)

# Dict[NodeType, int], List[ResourceDict]
to_launch, unfulfilled = self.resource_demand_scheduler.get_nodes_to_launch(
self.non_terminated_nodes.all_node_ids,
Expand Down
2 changes: 2 additions & 0 deletions python/ray/tests/test_autoscaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3620,7 +3620,9 @@ def testScaleDownIdleTimeOut(self):
worker_ip = self.provider.non_terminated_node_ips(WORKER_FILTER)[0]
# Mark the node as idle
lm.update(worker_ip, mock_raylet_id(), {"CPU": 1}, {"CPU": 1}, 20)
assert lm.is_active(worker_ip)
autoscaler.update()
assert not lm.is_active(worker_ip)
Comment on lines +3623 to +3625
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lm.is_active(worker_ip) should still be True before autoscaler.update().
lm.is_active(worker_ip) should be False after autoscaler.update() because the idle worker_ip should be pruned by the change in this PR.

assert self.provider.internal_ip("1") == worker_ip
events = autoscaler.event_summarizer.summary()
assert "Removing 1 nodes of type worker (idle)." in events, events
Expand Down