-
Notifications
You must be signed in to change notification settings - Fork 15
Fix node registration, filtergateway, and scenario processing bugs #400
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
base: main
Are you sure you want to change the base?
Changes from all commits
d940e36
04c6586
5574849
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good. |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I deeply appreciate your contribution. This section inserts a random node when the package fails to find a node to run on. As a result, the code shouldn't be executed, and it would be better to fundamentally change the part before this point. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,17 +12,30 @@ use prost::Message; | |
| use std::error::Error; | ||
|
|
||
| /// Find a node by IP address from simplified node keys | ||
| /// Filters out invalid IPs like 0.0.0.0 and empty strings | ||
| pub async fn find_node_by_simple_key() -> Option<String> { | ||
| println!("Checking simplified node keys in etcd..."); | ||
| match etcd::get_all_with_prefix("nodes/").await { | ||
| Ok(kvs) => { | ||
| println!("Found {} simplified node keys", kvs.len()); | ||
| if let Some(kv) = kvs.first() { | ||
| // Iterate through all nodes and find the first valid IP | ||
| for kv in kvs { | ||
| println!("Node key: {}", kv.key); | ||
| let ip_address = kv.key.trim_start_matches("nodes/"); | ||
| println!("Found node IP directly from key: {}", ip_address); | ||
|
|
||
| // Skip invalid IPs: empty, 0.0.0.0, or localhost when looking for remote nodes | ||
| if ip_address.is_empty() | ||
| || ip_address == "0.0.0.0" | ||
| || ip_address == "127.0.0.1" | ||
| { | ||
| println!("Skipping invalid IP: {}", ip_address); | ||
| continue; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sometimes, IP can be |
||
| } | ||
|
|
||
| println!("Found valid node IP from key: {}", ip_address); | ||
| return Some(ip_address.to_string()); | ||
| } | ||
| println!("No valid node IPs found in simplified keys"); | ||
| None | ||
| } | ||
| Err(e) => { | ||
|
|
@@ -32,6 +45,32 @@ pub async fn find_node_by_simple_key() -> Option<String> { | |
| } | ||
| } | ||
|
|
||
| /// Find a node by specific target IP address from simplified node keys | ||
| /// Returns the IP if it exists and is valid, None otherwise | ||
| pub async fn find_node_by_target_ip(target_ip: &str) -> Option<String> { | ||
| if target_ip.is_empty() || target_ip == "0.0.0.0" { | ||
| return None; | ||
| } | ||
|
|
||
| println!("Looking for specific node IP: {}", target_ip); | ||
| let key = format!("nodes/{}", target_ip); | ||
|
|
||
| match etcd::get(&key).await { | ||
| Ok(Some(_)) => { | ||
| println!("Found target node IP in etcd: {}", target_ip); | ||
| Some(target_ip.to_string()) | ||
| } | ||
| Ok(None) => { | ||
| println!("Target node IP not found in etcd: {}", target_ip); | ||
| None | ||
| } | ||
| Err(e) => { | ||
| println!("Error checking for target IP {}: {}", target_ip, e); | ||
| None | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Find a node directly from etcd using cluster/nodes/ prefix | ||
| pub async fn find_node_from_etcd() -> Option<String> { | ||
| println!("Checking cluster/nodes/ prefix in etcd..."); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice bug fix