aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-19 23:53:49 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-19 23:53:49 +0200
commitf1a68f6b577af00f0989a46639345e4447b8f9dc (patch)
tree39f8c113a5dfe60906a786fe3759ced829b26806
parentd9c52e9a9c260ee2ec3350a253f6e6e8ae966b26 (diff)
downloadgarage-f1a68f6b577af00f0989a46639345e4447b8f9dc.tar.gz
garage-f1a68f6b577af00f0989a46639345e4447b8f9dc.zip
Fix clippy
-rw-r--r--src/garage/admin_rpc.rs6
-rw-r--r--src/garage/cli.rs3
-rw-r--r--src/garage/main.rs7
-rw-r--r--src/model/block.rs4
-rw-r--r--src/model/garage.rs7
-rw-r--r--src/rpc/system.rs35
-rw-r--r--src/util/config.rs2
-rw-r--r--src/util/data.rs6
8 files changed, 30 insertions, 40 deletions
diff --git a/src/garage/admin_rpc.rs b/src/garage/admin_rpc.rs
index 339d5bdb..b5fc9a7e 100644
--- a/src/garage/admin_rpc.rs
+++ b/src/garage/admin_rpc.rs
@@ -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);
}
}
diff --git a/src/garage/cli.rs b/src/garage/cli.rs
index 3f3a255f..63bb506a 100644
--- a/src/garage/cli.rs
+++ b/src/garage/cli.rs
@@ -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,
));
}
}
diff --git a/src/garage/main.rs b/src/garage/main.rs
index c4f75348..57767df1 100644
--- a/src/garage/main.rs
+++ b/src/garage/main.rs
@@ -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(())
diff --git a/src/model/block.rs b/src/model/block.rs
index a1dcf776..1e04ee58 100644
--- a/src/model/block.rs
+++ b/src/model/block.rs
@@ -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,
diff --git a/src/model/garage.rs b/src/model/garage.rs
index 482c4df7..d12c781f 100644
--- a/src/model/garage.rs
+++ b/src/model/garage.rs
@@ -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 {
diff --git a/src/rpc/system.rs b/src/rpc/system.rs
index 51abede3..68edabdf 100644
--- a/src/rpc/system.rs
+++ b/src/rpc/system.rs
@@ -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
diff --git a/src/util/config.rs b/src/util/config.rs
index 5ce5aa17..ed17f13c 100644
--- a/src/util/config.rs
+++ b/src/util/config.rs
@@ -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));
}
}
diff --git a/src/util/data.rs b/src/util/data.rs
index d4fe0009..6b8ee527 100644
--- a/src/util/data.rs
+++ b/src/util/data.rs
@@ -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()
}
}