-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix connectivity issues in Docker Swarm #270
Conversation
Add config field to set ip address for node
bob-apps/bin/bobd.rs
Outdated
let mut addr = node.bind().to_socket_addrs().unwrap().next().unwrap(); | ||
|
||
let mut addr = if let Some(addr) = node.bind_to_ip_address() { | ||
addr |
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.
Sanity check is required: if bind_to_ip_address
is specified and node
address is also specified as ipv4 and they are different, then log error and panic
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.
Done
bob-apps/bin/bobd.rs
Outdated
|
||
let mut addr = if let Some(addr) = node.bind_to_ip_address() { | ||
addr | ||
} else if let Ok(addr) = node.bind().parse() { |
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.
Into what type is this string parsed?
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.
std::net::SocketAddr
@pyakushin this change is needed ASAP. Please, review it. |
bob-apps/bin/bobd.rs
Outdated
@@ -44,8 +63,15 @@ async fn main() { | |||
.find(|n| n.name() == name) | |||
.unwrap_or_else(|| panic!("cannot find node: '{}' in cluster config", name)); | |||
mapper = VirtualMapper::new(&node, &cluster).await; | |||
addr = finded.address().to_socket_addrs().unwrap().next().unwrap(); | |||
addr = if let Ok(addr) = finded.address().parse() { |
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.
Typo: finded -> found
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.
Fixed
bob-apps/bin/bobd.rs
Outdated
} | ||
(Some(addr), _, _) => Some(addr), | ||
(_, Ok(addr), _) => Some(addr), | ||
(_, _, Some(port)) => Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), port)), |
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.
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), port)
occured multiple times in the code, prob it's better to add some function for it (since it's quite a long line)
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.
Or type
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.
Function created
bob-apps/bin/bobd.rs
Outdated
} | ||
(Some(addr), _, _) => Some(addr), | ||
(_, Ok(addr), _) => Some(addr), | ||
(_, _, Some(port)) => Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), port)), |
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.
Or type
bob-common/src/node.rs
Outdated
@@ -39,8 +38,7 @@ pub struct Disk { | |||
impl Node { | |||
pub async fn new(name: String, address: &str, index: u16) -> Self { | |||
error!("address: [{}]", address); |
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.
debug code
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.
Fixed
bob-common/src/node.rs
Outdated
@@ -39,8 +38,7 @@ pub struct Disk { | |||
impl Node { | |||
pub async fn new(name: String, address: &str, index: u16) -> Self { | |||
error!("address: [{}]", address); | |||
let mut address = lookup_host(address).await.expect("DNS resolution failed"); | |||
let address = address.next().expect("address is empty"); | |||
let address = address.to_string(); |
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.
Pass address as String
already because you make it owned here anyway
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.
Fixed
Closes #249