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

Remove unnecessary AsyncGetResources in NodeManager::NodeAdded #36412

Merged
merged 1 commit into from
Jun 14, 2023
Merged
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
Remove unnecessary AsyncGetResources in NodeManager::NodeAdded
Signed-off-by: Jiajun Yao <[email protected]>
  • Loading branch information
jjyao committed Jun 14, 2023
commit d98d11e0102bdb12f9a5fc200f146237fd94ba40
47 changes: 19 additions & 28 deletions src/ray/raylet/node_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -989,39 +989,30 @@ void NodeManager::NodeAdded(const GcsNodeInfo &node_info) {
remote_node_manager_addresses_[node_id] =
std::make_pair(node_info.node_manager_address(), node_info.node_manager_port());

// Reset node labels when node added.
// Set node labels when node added.
absl::flat_hash_map<std::string, std::string> labels(node_info.labels().begin(),
node_info.labels().end());
cluster_resource_scheduler_->GetClusterResourceManager().SetNodeLabels(
scheduling::NodeID(node_id.Binary()), labels);

// Fetch resource info for the remote node and update cluster resource map.
RAY_CHECK_OK(gcs_client_->NodeResources().AsyncGetResources(
node_id,
[this, node_id](
Status status,
const boost::optional<gcs::NodeResourceInfoAccessor::ResourceMap> &data) {
// TODO: Always use the message from ray syncer.
if (data) {
ResourceRequest resources;
for (auto &resource_entry : *data) {
resources.Set(scheduling::ResourceID(resource_entry.first),
FixedPoint(resource_entry.second->resource_capacity()));
}
if (ResourceCreateUpdated(node_id, resources)) {
cluster_task_manager_->ScheduleAndDispatchTasks();
}
}
// Update the resource view if a new message has been sent.
if (RayConfig::instance().use_ray_syncer()) {
if (auto sync_msg = ray_syncer_.GetSyncMessage(
node_id.Binary(), syncer::MessageType::RESOURCE_VIEW)) {
if (sync_msg) {
ConsumeSyncMessage(sync_msg);
}
}
}
}));
// TODO: Always use the message from ray syncer.
ResourceRequest resources;
for (auto &resource_entry : node_info.resources_total()) {
resources.Set(scheduling::ResourceID(resource_entry.first),
FixedPoint(resource_entry.second));
}
if (ResourceCreateUpdated(node_id, resources)) {
cluster_task_manager_->ScheduleAndDispatchTasks();
}
// Update the resource view if a new message has been sent.
if (RayConfig::instance().use_ray_syncer()) {
if (auto sync_msg = ray_syncer_.GetSyncMessage(node_id.Binary(),
syncer::MessageType::RESOURCE_VIEW)) {
if (sync_msg) {
ConsumeSyncMessage(sync_msg);
}
}
}
}

void NodeManager::NodeRemoved(const NodeID &node_id) {
Expand Down