From 9178de819c6fd74ff3564e0b109addda301492f5 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Fri, 24 Jan 2025 19:21:08 +0100 Subject: [PATCH] db-snapshot: propagate any node snapshot error through RPC call In particular, it means that "garage meta snapshot --all" will get an exit code of 1 if any node fails to snapshot. This makes sure that any external tool trying to snapshot nodes (e.g. from cron) will be aware of the failure. Fix #920 --- src/garage/admin/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/garage/admin/mod.rs b/src/garage/admin/mod.rs index 823afc59..ab530ebf 100644 --- a/src/garage/admin/mod.rs +++ b/src/garage/admin/mod.rs @@ -495,7 +495,14 @@ impl AdminRpcHandler { ret.push(format!("{:?}\t{}", to, res_str)); } - Ok(AdminRpc::Ok(format_table_to_string(ret))) + if resps.iter().any(|resp| match resp { + Err(_) => true, + Ok(_) => false, + }) { + Err(Error::BadRequest(format_table_to_string(ret)).into()) + } else { + Ok(AdminRpc::Ok(format_table_to_string(ret))) + } } MetaOperation::Snapshot { all: false } => { garage_model::snapshot::async_snapshot_metadata(&self.garage).await?;