Fix clippy

This commit is contained in:
Alex 2021-10-19 23:53:49 +02:00
parent d9c52e9a9c
commit f1a68f6b57
No known key found for this signature in database
GPG key ID: EDABF9711E244EB1
8 changed files with 30 additions and 40 deletions

View file

@ -349,11 +349,7 @@ impl AdminRpcHandler {
PRIO_NORMAL, PRIO_NORMAL,
) )
.await; .await;
let is_err = match resp { if !matches!(resp, Ok(Ok(_))) {
Ok(Ok(_)) => false,
_ => true,
};
if is_err {
failures.push(node); failures.push(node);
} }
} }

View file

@ -5,7 +5,6 @@ use structopt::StructOpt;
use garage_util::data::Uuid; use garage_util::data::Uuid;
use garage_util::error::Error; use garage_util::error::Error;
use garage_util::time::*;
use garage_rpc::ring::*; use garage_rpc::ring::*;
use garage_rpc::system::*; use garage_rpc::system::*;
@ -400,7 +399,7 @@ pub async fn cmd_status(rpc_cli: &Endpoint<SystemRpc, ()>, rpc_host: NodeID) ->
tag = cfg.tag, tag = cfg.tag,
zone = cfg.zone, zone = cfg.zone,
capacity = cfg.capacity_string(), capacity = cfg.capacity_string(),
last_seen = (now_msec() - 0) / 1000, last_seen = "FIXME", // FIXME was (now_msec() - adv.last_seen) / 1000,
)); ));
} }
} }

View file

@ -145,12 +145,12 @@ fn node_id_command(config_file: PathBuf, quiet: bool) -> Result<(), Error> {
}; };
if !quiet { if !quiet {
eprintln!(""); eprintln!();
eprintln!( eprintln!(
"To instruct a node to connect to this node, run the following command on that node:" "To instruct a node to connect to this node, run the following command on that node:"
); );
eprintln!(" garage [-c <config file path>] node connect {}", idstr); eprintln!(" garage [-c <config file path>] node connect {}", idstr);
eprintln!(""); eprintln!();
eprintln!("Or instruct them to connect from here by running:"); eprintln!("Or instruct them to connect from here by running:");
eprintln!( eprintln!(
" garage -c {} -h <remote node> node connect {}", " garage -c {} -h <remote node> node connect {}",
@ -160,12 +160,13 @@ fn node_id_command(config_file: PathBuf, quiet: bool) -> Result<(), Error> {
eprintln!( eprintln!(
"where <remote_node> is their own node identifier in the format: <pubkey>@<ip>:<port>" "where <remote_node> is their own node identifier in the format: <pubkey>@<ip>:<port>"
); );
eprintln!(""); eprintln!();
eprintln!("This node identifier can also be added as a bootstrap node in other node's garage.toml files:"); eprintln!("This node identifier can also be added as a bootstrap node in other node's garage.toml files:");
eprintln!(" bootstrap_peers = ["); eprintln!(" bootstrap_peers = [");
eprintln!(" \"{}\",", idstr); eprintln!(" \"{}\",", idstr);
eprintln!(" ..."); eprintln!(" ...");
eprintln!(" ]"); eprintln!(" ]");
eprintln!();
} }
Ok(()) Ok(())

View file

@ -98,7 +98,9 @@ impl BlockManager {
.open_tree("block_local_resync_queue") .open_tree("block_local_resync_queue")
.expect("Unable to open block_local_resync_queue tree"); .expect("Unable to open block_local_resync_queue tree");
let endpoint = system.netapp.endpoint(format!("garage_model/block.rs/Rpc")); let endpoint = system
.netapp
.endpoint("garage_model/block.rs/Rpc".to_string());
let block_manager = Arc::new(Self { let block_manager = Arc::new(Self {
replication, replication,

View file

@ -57,14 +57,9 @@ impl Garage {
info!("Initialize membership management system..."); info!("Initialize membership management system...");
let system = System::new( let system = System::new(
network_key, network_key,
config.metadata_dir.clone(),
background.clone(), background.clone(),
replication_mode.replication_factor(), replication_mode.replication_factor(),
config.rpc_bind_addr, &config,
config.rpc_public_addr,
config.bootstrap_peers.clone(),
config.consul_host.clone(),
config.consul_service_name.clone(),
); );
let data_rep_param = TableShardedReplication { let data_rep_param = TableShardedReplication {

View file

@ -2,7 +2,7 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::net::SocketAddr; use std::net::SocketAddr;
use std::path::{Path, PathBuf}; use std::path::Path;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use std::time::Duration; use std::time::Duration;
@ -22,6 +22,7 @@ use netapp::util::parse_and_resolve_peer_addr;
use netapp::{NetApp, NetworkKey, NodeID, NodeKey}; use netapp::{NetApp, NetworkKey, NodeID, NodeKey};
use garage_util::background::BackgroundRunner; use garage_util::background::BackgroundRunner;
use garage_util::config::Config;
use garage_util::data::Uuid; use garage_util::data::Uuid;
use garage_util::error::Error; use garage_util::error::Error;
use garage_util::persister::Persister; use garage_util::persister::Persister;
@ -137,19 +138,15 @@ impl System {
/// Create this node's membership manager /// Create this node's membership manager
pub fn new( pub fn new(
network_key: NetworkKey, network_key: NetworkKey,
metadata_dir: PathBuf,
background: Arc<BackgroundRunner>, background: Arc<BackgroundRunner>,
replication_factor: usize, replication_factor: usize,
rpc_listen_addr: SocketAddr, config: &Config,
rpc_public_address: Option<SocketAddr>,
bootstrap_peers: Vec<(NodeID, SocketAddr)>,
consul_host: Option<String>,
consul_service_name: Option<String>,
) -> Arc<Self> { ) -> Arc<Self> {
let node_key = gen_node_key(&metadata_dir).expect("Unable to read or generate node ID"); let node_key =
gen_node_key(&config.metadata_dir).expect("Unable to read or generate node ID");
info!("Node public key: {}", hex::encode(&node_key.public_key())); info!("Node public key: {}", hex::encode(&node_key.public_key()));
let persist_config = Persister::new(&metadata_dir, "network_config"); let persist_config = Persister::new(&config.metadata_dir, "network_config");
let net_config = match persist_config.load() { let net_config = match persist_config.load() {
Ok(x) => x, Ok(x) => x,
@ -166,14 +163,14 @@ impl System {
hostname: gethostname::gethostname() hostname: gethostname::gethostname()
.into_string() .into_string()
.unwrap_or_else(|_| "<invalid utf-8>".to_string()), .unwrap_or_else(|_| "<invalid utf-8>".to_string()),
replication_factor: replication_factor, replication_factor,
config_version: net_config.version, config_version: net_config.version,
}; };
let ring = Ring::new(net_config, replication_factor); let ring = Ring::new(net_config, replication_factor);
let (update_ring, ring) = watch::channel(Arc::new(ring)); let (update_ring, ring) = watch::channel(Arc::new(ring));
if let Some(addr) = rpc_public_address { if let Some(addr) = config.rpc_public_addr {
println!("{}@{}", hex::encode(&node_key.public_key()), addr); println!("{}@{}", hex::encode(&node_key.public_key()), addr);
} else { } else {
println!("{}", hex::encode(&node_key.public_key())); println!("{}", hex::encode(&node_key.public_key()));
@ -182,8 +179,8 @@ impl System {
let netapp = NetApp::new(network_key, node_key); let netapp = NetApp::new(network_key, node_key);
let fullmesh = FullMeshPeeringStrategy::new( let fullmesh = FullMeshPeeringStrategy::new(
netapp.clone(), netapp.clone(),
bootstrap_peers.clone(), config.bootstrap_peers.clone(),
rpc_public_address, config.rpc_public_addr,
); );
let system_endpoint = netapp.endpoint(SYSTEM_RPC_PATH.into()); let system_endpoint = netapp.endpoint(SYSTEM_RPC_PATH.into());
@ -196,18 +193,18 @@ impl System {
netapp: netapp.clone(), netapp: netapp.clone(),
fullmesh: fullmesh.clone(), fullmesh: fullmesh.clone(),
rpc: RpcHelper { rpc: RpcHelper {
fullmesh: fullmesh.clone(), fullmesh,
background: background.clone(), background: background.clone(),
}, },
system_endpoint, system_endpoint,
replication_factor, replication_factor,
rpc_listen_addr, rpc_listen_addr: config.rpc_bind_addr,
bootstrap_peers, bootstrap_peers: config.bootstrap_peers.clone(),
consul_host, consul_host: config.consul_host.clone(),
consul_service_name, consul_service_name: config.consul_service_name.clone(),
ring, ring,
update_ring: Mutex::new(update_ring), update_ring: Mutex::new(update_ring),
background: background.clone(), background,
}); });
sys.system_endpoint.set_handler(sys.clone()); sys.system_endpoint.set_handler(sys.clone());
sys sys

View file

@ -114,7 +114,7 @@ where
D::Error::custom(format!("Unable to parse or resolve peer: {}", peer)) D::Error::custom(format!("Unable to parse or resolve peer: {}", peer))
})?; })?;
for ip in addrs { for ip in addrs {
ret.push((pubkey.clone(), ip)); ret.push((pubkey, ip));
} }
} }

View file

@ -93,9 +93,9 @@ impl From<netapp::NodeID> for FixedBytes32 {
} }
} }
impl Into<netapp::NodeID> for FixedBytes32 { impl From<FixedBytes32> for netapp::NodeID {
fn into(self) -> netapp::NodeID { fn from(bytes: FixedBytes32) -> netapp::NodeID {
netapp::NodeID::from_slice(self.as_slice()).unwrap() netapp::NodeID::from_slice(bytes.as_slice()).unwrap()
} }
} }