Improve error message on rpc connection failure
This commit is contained in:
parent
d56c472712
commit
a19bfef508
1 changed files with 9 additions and 7 deletions
|
@ -50,8 +50,6 @@ pub const GARAGE_VERSION_TAG: u64 = 0x6761726167650008; // garage 0x0008
|
||||||
/// RPC endpoint used for calls related to membership
|
/// RPC endpoint used for calls related to membership
|
||||||
pub const SYSTEM_RPC_PATH: &str = "garage_rpc/membership.rs/SystemRpc";
|
pub const SYSTEM_RPC_PATH: &str = "garage_rpc/membership.rs/SystemRpc";
|
||||||
|
|
||||||
pub const CONNECT_ERROR_MESSAGE: &str = "Error establishing RPC connection to remote node. This can happen if the remote node is not reachable on the network, but also if the two nodes are not configured with the same rpc_secret";
|
|
||||||
|
|
||||||
/// RPC messages related to membership
|
/// RPC messages related to membership
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub enum SystemRpc {
|
pub enum SystemRpc {
|
||||||
|
@ -438,17 +436,17 @@ impl System {
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
let mut errors = vec![];
|
let mut errors = vec![];
|
||||||
for ip in addrs.iter() {
|
for addr in addrs.iter() {
|
||||||
match self
|
match self
|
||||||
.netapp
|
.netapp
|
||||||
.clone()
|
.clone()
|
||||||
.try_connect(*ip, pubkey)
|
.try_connect(*addr, pubkey)
|
||||||
.await
|
.await
|
||||||
.err_context(CONNECT_ERROR_MESSAGE)
|
.err_context(connect_error_message(*addr, pubkey))
|
||||||
{
|
{
|
||||||
Ok(()) => return Ok(()),
|
Ok(()) => return Ok(()),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
errors.push((*ip, e));
|
errors.push((*addr, e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -772,7 +770,7 @@ impl System {
|
||||||
self.netapp
|
self.netapp
|
||||||
.clone()
|
.clone()
|
||||||
.try_connect(node_addr, node_id)
|
.try_connect(node_addr, node_id)
|
||||||
.map(|r| r.err_context(CONNECT_ERROR_MESSAGE)),
|
.map(move |r| r.err_context(connect_error_message(node_addr, node_id))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -875,3 +873,7 @@ async fn resolve_peers(peers: &[String]) -> Vec<(NodeID, SocketAddr)> {
|
||||||
|
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn connect_error_message(addr: SocketAddr, pubkey: ed25519::PublicKey) -> String {
|
||||||
|
format!("Error establishing RPC connection to remote node: {}@{}.\nThis can happen if the remote node is not reachable on the network, but also if the two nodes are not configured with the same rpc_secret", hex::encode(pubkey), addr)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue