aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-06 16:37:44 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-06 16:37:44 +0200
commitc3c8d59c996061a2a4280820915a6dcd94cf496c (patch)
tree218100fda6320495466a150580ecaf6e469fbb8e
parentbbf68aa039678d844e7d88db1a23a128f877ba43 (diff)
downloadgarage-c3c8d59c996061a2a4280820915a6dcd94cf496c.tar.gz
garage-c3c8d59c996061a2a4280820915a6dcd94cf496c.zip
Fix more .unwrap()'s
-rw-r--r--src/block/metrics.rs8
-rw-r--r--src/table/metrics.rs20
-rw-r--r--src/table/sync.rs13
3 files changed, 28 insertions, 13 deletions
diff --git a/src/block/metrics.rs b/src/block/metrics.rs
index 1d4d0028..0bd50a18 100644
--- a/src/block/metrics.rs
+++ b/src/block/metrics.rs
@@ -28,7 +28,9 @@ impl BlockManagerMetrics {
Self {
_resync_queue_len: meter
.u64_value_observer("block.resync_queue_length", move |observer| {
- observer.observe(resync_queue.len().unwrap() as u64, &[]) // TODO fix unwrap
+ if let Ok(v) = resync_queue.len() {
+ observer.observe(v as u64, &[]);
+ }
})
.with_description(
"Number of block hashes queued for local check and possible resync",
@@ -36,7 +38,9 @@ impl BlockManagerMetrics {
.init(),
_resync_errored_blocks: meter
.u64_value_observer("block.resync_errored_blocks", move |observer| {
- observer.observe(resync_errors.len().unwrap() as u64, &[]) // TODO fix unwrap
+ if let Ok(v) = resync_errors.len() {
+ observer.observe(v as u64, &[]);
+ }
})
.with_description("Number of block hashes whose last resync resulted in an error")
.init(),
diff --git a/src/table/metrics.rs b/src/table/metrics.rs
index 3318de88..13baf4c6 100644
--- a/src/table/metrics.rs
+++ b/src/table/metrics.rs
@@ -26,10 +26,12 @@ impl TableMetrics {
.u64_value_observer(
"table.merkle_updater_todo_queue_length",
move |observer| {
- observer.observe(
- merkle_todo.len().unwrap() as u64, // TODO fix unwrap
- &[KeyValue::new("table_name", table_name)],
- )
+ if let Ok(v) = merkle_todo.len() {
+ observer.observe(
+ v as u64,
+ &[KeyValue::new("table_name", table_name)],
+ );
+ }
},
)
.with_description("Merkle tree updater TODO queue length")
@@ -38,10 +40,12 @@ impl TableMetrics {
.u64_value_observer(
"table.gc_todo_queue_length",
move |observer| {
- observer.observe(
- gc_todo.len().unwrap() as u64, // TODO fix unwrap
- &[KeyValue::new("table_name", table_name)],
- )
+ if let Ok(v) = gc_todo.len() {
+ observer.observe(
+ v as u64,
+ &[KeyValue::new("table_name", table_name)],
+ );
+ }
},
)
.with_description("Table garbage collector TODO queue length")
diff --git a/src/table/sync.rs b/src/table/sync.rs
index 20066d73..4c83e991 100644
--- a/src/table/sync.rs
+++ b/src/table/sync.rs
@@ -603,9 +603,16 @@ impl SyncTodo {
let retain = nodes.contains(&my_id);
if !retain {
// Check if we have some data to send, otherwise skip
- if data.store.range(begin..end).unwrap().next().is_none() {
- // TODO fix unwrap
- continue;
+ match data.store.range(begin..end) {
+ Ok(mut iter) => {
+ if iter.next().is_none() {
+ continue;
+ }
+ }
+ Err(e) => {
+ warn!("DB error in add_full_sync: {}", e);
+ continue;
+ }
}
}