aboutsummaryrefslogtreecommitdiff
path: root/src/garage/cli/layout.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-02-10 16:10:21 +0100
committerAlex Auvolat <alex@adnab.me>2022-03-24 15:27:10 +0100
commit413ab0eaedb12b8808897098263cefa4bc7a7663 (patch)
tree2a9a47cf07d4c69ee7ab4b257ce9de944a43e211 /src/garage/cli/layout.rs
parent43945234ae15734def2a9d29ee0880a7156c25a6 (diff)
downloadgarage-413ab0eaedb12b8808897098263cefa4bc7a7663.tar.gz
garage-413ab0eaedb12b8808897098263cefa4bc7a7663.zip
Small change to partition assignation algorithm
This change helps ensure that nodes for each partition are spread over all datacenters, a property that wasn't ensured previously when going from a 2 DC deployment to a 3 DC deployment
Diffstat (limited to 'src/garage/cli/layout.rs')
-rw-r--r--src/garage/cli/layout.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/garage/cli/layout.rs b/src/garage/cli/layout.rs
index 0d9e4fa4..e0aba1d1 100644
--- a/src/garage/cli/layout.rs
+++ b/src/garage/cli/layout.rs
@@ -196,6 +196,15 @@ pub async fn cmd_apply_layout(
) -> Result<(), Error> {
let mut layout = fetch_layout(rpc_cli, rpc_host).await?;
+ layout.roles.merge(&layout.staging);
+
+ if !layout.calculate_partition_assignation() {
+ return Err(Error::Message("Could not calculate new assignation of partitions to nodes. This can happen if there are less nodes than the desired number of copies of your data (see the replication_mode configuration parameter).".into()));
+ }
+
+ layout.staging.clear();
+ layout.staging_hash = blake2sum(&rmp_to_vec_all_named(&layout.staging).unwrap()[..]);
+
match apply_opt.version {
None => {
println!("Please pass the --version flag to ensure that you are writing the correct version of the cluster layout.");
@@ -209,15 +218,6 @@ pub async fn cmd_apply_layout(
}
}
- layout.roles.merge(&layout.staging);
-
- if !layout.calculate_partition_assignation() {
- return Err(Error::Message("Could not calculate new assignation of partitions to nodes. This can happen if there are less nodes than the desired number of copies of your data (see the replication_mode configuration parameter).".into()));
- }
-
- layout.staging.clear();
- layout.staging_hash = blake2sum(&rmp_to_vec_all_named(&layout.staging).unwrap()[..]);
-
layout.version += 1;
send_layout(rpc_cli, rpc_host, layout).await?;