aboutsummaryrefslogtreecommitdiff
path: root/src/garage
diff options
context:
space:
mode:
authorMendes <mendes.oulamara@pm.me>2022-10-05 15:29:48 +0200
committerMendes <mendes.oulamara@pm.me>2022-10-05 15:29:48 +0200
commitceac3713d6639f9170fc3b4475fae4a30b34483c (patch)
treebb05a4272587ab69969eba39b0e5c5e3fbb5a529 /src/garage
parent829f815a897b04986559910bbcbf53625adcdf20 (diff)
downloadgarage-ceac3713d6639f9170fc3b4475fae4a30b34483c.tar.gz
garage-ceac3713d6639f9170fc3b4475fae4a30b34483c.zip
modifications in several files to :
- have consistent error return types - store the zone redundancy in a Lww - print the error and message in the CLI (TODO: for the server Api, should msg be returned in the body response?)
Diffstat (limited to 'src/garage')
-rw-r--r--src/garage/cli/layout.rs35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/garage/cli/layout.rs b/src/garage/cli/layout.rs
index 3884bb92..a5b838e7 100644
--- a/src/garage/cli/layout.rs
+++ b/src/garage/cli/layout.rs
@@ -188,19 +188,23 @@ pub async fn cmd_show_layout(
// this will print the stats of what partitions
// will move around when we apply
- if layout.calculate_partition_assignation() {
- println!("To enact the staged role changes, type:");
- println!();
- println!(" garage layout apply --version {}", layout.version + 1);
- println!();
- println!(
- "You can also revert all proposed changes with: garage layout revert --version {}",
- layout.version + 1
- );
- } else {
- println!("Not enough nodes have an assigned role to maintain enough copies of data.");
- println!("This new layout cannot yet be applied.");
- }
+ match layout.calculate_partition_assignation() {
+ Ok(msg) => {
+ for line in msg.iter() {
+ println!("{}", line);
+ }
+ println!("To enact the staged role changes, type:");
+ println!();
+ println!(" garage layout apply --version {}", layout.version + 1);
+ println!();
+ println!(
+ "You can also revert all proposed changes with: garage layout revert --version {}",
+ layout.version + 1)},
+ Err(Error::Message(s)) => {
+ println!("Error while trying to compute the assignation: {}", s);
+ println!("This new layout cannot yet be applied.");},
+ _ => { println!("Unknown Error"); },
+ }
}
Ok(())
@@ -213,7 +217,10 @@ pub async fn cmd_apply_layout(
) -> Result<(), Error> {
let layout = fetch_layout(rpc_cli, rpc_host).await?;
- let layout = layout.apply_staged_changes(apply_opt.version)?;
+ let (layout, msg) = layout.apply_staged_changes(apply_opt.version)?;
+ for line in msg.iter() {
+ println!("{}", line);
+ }
send_layout(rpc_cli, rpc_host, layout).await?;