aboutsummaryrefslogtreecommitdiff
path: root/src/garage
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-04-05 19:55:53 +0200
committerAlex Auvolat <alex@adnab.me>2021-04-27 16:37:08 +0200
commit9ced9f78dcc3894b3c2f13b8a95653f990278f03 (patch)
tree00b5180edcfab392eef203f594edb1332ccfce5d /src/garage
parent3a449badb125b4f5bf0497639745a583bc949da2 (diff)
downloadgarage-9ced9f78dcc3894b3c2f13b8a95653f990278f03.tar.gz
garage-9ced9f78dcc3894b3c2f13b8a95653f990278f03.zip
Improve bootstraping: do it regularly; persist peer list
Diffstat (limited to 'src/garage')
-rw-r--r--src/garage/admin_rpc.rs4
-rw-r--r--src/garage/cli.rs12
-rw-r--r--src/garage/server.rs2
3 files changed, 11 insertions, 7 deletions
diff --git a/src/garage/admin_rpc.rs b/src/garage/admin_rpc.rs
index df00fcaf..d04dd7a1 100644
--- a/src/garage/admin_rpc.rs
+++ b/src/garage/admin_rpc.rs
@@ -246,15 +246,13 @@ impl AdminRpcHandler {
)))
}
KeyOperation::Import(query) => {
- let prev_key = self.garage.key_table.get(&EmptyKey, &query.key_id)
- .await?;
+ let prev_key = self.garage.key_table.get(&EmptyKey, &query.key_id).await?;
if prev_key.is_some() {
return Err(Error::Message(format!("Key {} already exists in data store. Even if it is deleted, we can't let you create a new key with the same ID. Sorry.", query.key_id)));
}
let imported_key = Key::import(&query.key_id, &query.secret_key, &query.name);
self.garage.key_table.insert(&imported_key).await?;
Ok(AdminRPC::KeyInfo(imported_key))
-
}
}
}
diff --git a/src/garage/cli.rs b/src/garage/cli.rs
index 886cf384..eb8275a9 100644
--- a/src/garage/cli.rs
+++ b/src/garage/cli.rs
@@ -5,8 +5,8 @@ use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use structopt::StructOpt;
-use garage_util::error::Error;
use garage_util::data::UUID;
+use garage_util::error::Error;
use garage_util::time::*;
use garage_rpc::membership::*;
@@ -384,7 +384,10 @@ pub async fn cmd_status(
Ok(())
}
-pub fn find_matching_node(cand: impl std::iter::Iterator<Item=UUID>, pattern: &str) -> Result<UUID, Error> {
+pub fn find_matching_node(
+ cand: impl std::iter::Iterator<Item = UUID>,
+ pattern: &str,
+) -> Result<UUID, Error> {
let mut candidates = vec![];
for c in cand {
if hex::encode(&c).starts_with(&pattern) {
@@ -428,7 +431,10 @@ pub async fn cmd_configure(
for replaced in args.replace.iter() {
let replaced_node = find_matching_node(config.members.keys().cloned(), replaced)?;
if config.members.remove(&replaced_node).is_none() {
- return Err(Error::Message(format!("Cannot replace node {:?} as it is not in current configuration", replaced_node)));
+ return Err(Error::Message(format!(
+ "Cannot replace node {:?} as it is not in current configuration",
+ replaced_node
+ )));
}
}
diff --git a/src/garage/server.rs b/src/garage/server.rs
index c45a69b8..feb858e4 100644
--- a/src/garage/server.rs
+++ b/src/garage/server.rs
@@ -52,7 +52,7 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
info!("Initializing Garage main data store...");
let garage = Garage::new(config.clone(), db, background, &mut rpc_server);
let bootstrap = garage.system.clone().bootstrap(
- &config.bootstrap_peers[..],
+ config.bootstrap_peers,
config.consul_host,
config.consul_service_name,
);