Fix clippy

This commit is contained in:
Alex Auvolat 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,
)
.await;
let is_err = match resp {
Ok(Ok(_)) => false,
_ => true,
};
if is_err {
if !matches!(resp, Ok(Ok(_))) {
failures.push(node);
}
}

View File

@ -5,7 +5,6 @@ use structopt::StructOpt;
use garage_util::data::Uuid;
use garage_util::error::Error;
use garage_util::time::*;
use garage_rpc::ring::*;
use garage_rpc::system::*;
@ -400,7 +399,7 @@ pub async fn cmd_status(rpc_cli: &Endpoint<SystemRpc, ()>, rpc_host: NodeID) ->
tag = cfg.tag,
zone = cfg.zone,
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 {
eprintln!("");
eprintln!();
eprintln!(
"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!("");
eprintln!();
eprintln!("Or instruct them to connect from here by running:");
eprintln!(
" garage -c {} -h <remote node> node connect {}",
@ -160,12 +160,13 @@ fn node_id_command(config_file: PathBuf, quiet: bool) -> Result<(), Error> {
eprintln!(
"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!(" bootstrap_peers = [");
eprintln!(" \"{}\",", idstr);
eprintln!(" ...");
eprintln!(" ]");
eprintln!();
}
Ok(())

View File

@ -98,7 +98,9 @@ impl BlockManager {
.open_tree("block_local_resync_queue")
.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 {
replication,

View File

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

View File

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

View File

@ -114,7 +114,7 @@ where
D::Error::custom(format!("Unable to parse or resolve peer: {}", peer))
})?;
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 {
fn into(self) -> netapp::NodeID {
netapp::NodeID::from_slice(self.as_slice()).unwrap()
impl From<FixedBytes32> for netapp::NodeID {
fn from(bytes: FixedBytes32) -> netapp::NodeID {
netapp::NodeID::from_slice(bytes.as_slice()).unwrap()
}
}