mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-07 21:33:13 +00:00
add error case for layout not ready, and fail earlier in many places
This commit is contained in:
@@ -227,7 +227,7 @@ impl<'a> BucketHelper<'a> {
|
||||
.0
|
||||
.system
|
||||
.cluster_layout()
|
||||
.all_nongateway_nodes()
|
||||
.all_nongateway_nodes()?
|
||||
.to_vec();
|
||||
let k2vindexes = self
|
||||
.0
|
||||
|
||||
@@ -84,17 +84,16 @@ impl<T: CountedItem> Entry<T::CP, T::CS> for CounterEntry<T> {
|
||||
|
||||
impl<T: CountedItem> CounterEntry<T> {
|
||||
pub fn filtered_values(&self, layout: &LayoutHelper) -> HashMap<String, i64> {
|
||||
let nodes = layout.all_nongateway_nodes();
|
||||
self.filtered_values_with_nodes(&nodes)
|
||||
self.filtered_values_internal(layout.all_nongateway_nodes().ok())
|
||||
}
|
||||
|
||||
pub fn filtered_values_with_nodes(&self, nodes: &[Uuid]) -> HashMap<String, i64> {
|
||||
fn filtered_values_internal(&self, nodes_opt: Option<&[Uuid]>) -> HashMap<String, i64> {
|
||||
let mut ret = HashMap::new();
|
||||
for (name, vals) in self.values.iter() {
|
||||
let new_vals = vals
|
||||
.node_values
|
||||
.iter()
|
||||
.filter(|(n, _)| nodes.contains(n))
|
||||
.filter(|(n, _)| nodes_opt.map(|nodes| nodes.contains(n)).unwrap_or(true))
|
||||
.map(|(_, (_, v))| *v)
|
||||
.collect::<Vec<_>>();
|
||||
if !new_vals.is_empty() {
|
||||
@@ -153,7 +152,7 @@ impl<T: CountedItem> TableSchema for CounterTable<T> {
|
||||
}
|
||||
|
||||
let is_tombstone = entry
|
||||
.filtered_values_with_nodes(&filter.1[..])
|
||||
.filtered_values_internal(Some(&filter.1[..]))
|
||||
.iter()
|
||||
.all(|(_, v)| *v == 0);
|
||||
filter.0.apply(is_tombstone)
|
||||
|
||||
@@ -126,7 +126,7 @@ impl K2VRpcHandler {
|
||||
.item_table
|
||||
.data
|
||||
.replication
|
||||
.storage_nodes(&partition.hash());
|
||||
.storage_nodes(&partition.hash())?;
|
||||
who.sort();
|
||||
|
||||
self.system
|
||||
@@ -165,7 +165,7 @@ impl K2VRpcHandler {
|
||||
.item_table
|
||||
.data
|
||||
.replication
|
||||
.storage_nodes(&partition.hash());
|
||||
.storage_nodes(&partition.hash())?;
|
||||
who.sort();
|
||||
|
||||
call_list.entry(who).or_default().push(InsertedItem {
|
||||
@@ -222,7 +222,7 @@ impl K2VRpcHandler {
|
||||
.item_table
|
||||
.data
|
||||
.replication
|
||||
.storage_nodes(&poll_key.partition.hash());
|
||||
.storage_nodes(&poll_key.partition.hash())?;
|
||||
|
||||
let rpc = self.system.rpc_helper().try_call_many(
|
||||
&self.endpoint,
|
||||
@@ -233,7 +233,7 @@ impl K2VRpcHandler {
|
||||
timeout_msec,
|
||||
},
|
||||
RequestStrategy::with_priority(PRIO_NORMAL)
|
||||
.with_quorum(self.item_table.data.replication.read_quorum())
|
||||
.with_quorum(self.item_table.data.replication.read_quorum()?)
|
||||
.send_all_at_once(true)
|
||||
.without_timeout(),
|
||||
);
|
||||
@@ -283,8 +283,8 @@ impl K2VRpcHandler {
|
||||
.item_table
|
||||
.data
|
||||
.replication
|
||||
.storage_nodes(&range.partition.hash());
|
||||
let quorum = self.item_table.data.replication.read_quorum();
|
||||
.storage_nodes(&range.partition.hash())?;
|
||||
let quorum = self.item_table.data.replication.read_quorum()?;
|
||||
let msg = K2VRpc::PollRange {
|
||||
range,
|
||||
seen_str,
|
||||
|
||||
Reference in New Issue
Block a user