diff options
author | Alex Auvolat <alex@adnab.me> | 2023-11-15 12:15:58 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-11-15 12:15:58 +0100 |
commit | b3e729f4b8ec3b06593f8d3b161c76b1263d9f13 (patch) | |
tree | 4c0d403a5bb961a4edb7e1e7462700a400ac4455 /src/rpc/layout/version.rs | |
parent | 7ef2c231208073db5a0a0a8674e2dd2d2ecb2222 (diff) | |
download | garage-b3e729f4b8ec3b06593f8d3b161c76b1263d9f13.tar.gz garage-b3e729f4b8ec3b06593f8d3b161c76b1263d9f13.zip |
layout history merge: rm invalid versions when valid versions are added
Diffstat (limited to 'src/rpc/layout/version.rs')
-rw-r--r-- | src/rpc/layout/version.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/rpc/layout/version.rs b/src/rpc/layout/version.rs index 912ee538..947fab56 100644 --- a/src/rpc/layout/version.rs +++ b/src/rpc/layout/version.rs @@ -174,6 +174,16 @@ impl LayoutVersion { /// (assignment, roles, parameters, partition size) /// returns true if consistent, false if error pub fn check(&self) -> Result<(), String> { + // Check that the assignment data has the correct length + let expected_assignment_data_len = (1 << PARTITION_BITS) * self.replication_factor; + if self.ring_assignment_data.len() != expected_assignment_data_len { + return Err(format!( + "ring_assignment_data has incorrect length {} instead of {}", + self.ring_assignment_data.len(), + expected_assignment_data_len + )); + } + // Check that node_id_vec contains the correct list of nodes let mut expected_nodes = self .roles @@ -189,16 +199,6 @@ impl LayoutVersion { return Err(format!("node_id_vec does not contain the correct set of nodes\nnode_id_vec: {:?}\nexpected: {:?}", node_id_vec, expected_nodes)); } - // Check that the assignment data has the correct length - let expected_assignment_data_len = (1 << PARTITION_BITS) * self.replication_factor; - if self.ring_assignment_data.len() != expected_assignment_data_len { - return Err(format!( - "ring_assignment_data has incorrect length {} instead of {}", - self.ring_assignment_data.len(), - expected_assignment_data_len - )); - } - // Check that the assigned nodes are correct identifiers // of nodes that are assigned a role // and that role is not the role of a gateway nodes |