Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit f4f1bfd

Browse files
authored
sync locations from discovery (#524)
1 parent 4320638 commit f4f1bfd

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

crates/orchestrator/src/discovery/monitor.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,19 @@ impl DiscoveryMonitor {
338338
node.ip_address = discovery_node.node.ip_address.clone();
339339
let _ = self.store_context.node_store.add_node(node.clone()).await;
340340
}
341+
if existing_node.location.is_none() && discovery_node.location.is_some() {
342+
info!(
343+
"Node {} location changed from None to {:?}",
344+
node_address, discovery_node.location
345+
);
346+
if let Some(location) = &discovery_node.location {
347+
let _ = self
348+
.store_context
349+
.node_store
350+
.update_node_location(&node_address, location)
351+
.await;
352+
}
353+
}
341354

342355
if existing_node.status == NodeStatus::Dead {
343356
if let (Some(last_change), Some(last_updated)) = (

crates/orchestrator/src/store/domains/node_store.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use log::info;
77
use redis::AsyncCommands;
88
use redis::Value;
99
use shared::models::heartbeat::TaskDetails;
10+
use shared::models::node::NodeLocation;
1011
use shared::models::task::TaskState;
1112
use std::sync::Arc;
1213

@@ -145,6 +146,21 @@ impl NodeStore {
145146
Ok(())
146147
}
147148

149+
pub async fn update_node_location(
150+
&self,
151+
node_address: &Address,
152+
location: &NodeLocation,
153+
) -> Result<()> {
154+
let mut con = self.redis.client.get_multiplexed_async_connection().await?;
155+
let node_key: String = format!("{}:{}", ORCHESTRATOR_BASE_KEY, node_address);
156+
let node_string: String = con.get(&node_key).await?;
157+
let mut node: OrchestratorNode = serde_json::from_str(&node_string)?;
158+
node.location = Some(location.clone());
159+
let node_string = node.to_string();
160+
let _: () = con.set(&node_key, node_string).await?;
161+
Ok(())
162+
}
163+
148164
pub async fn update_node_p2p_id(&self, node_address: &Address, p2p_id: &str) -> Result<()> {
149165
let mut con = self.redis.client.get_multiplexed_async_connection().await?;
150166
let node_key: String = format!("{}:{}", ORCHESTRATOR_BASE_KEY, node_address);

0 commit comments

Comments
 (0)