forked from Deuxfleurs/garage
Merge pull request 'fix crash in layout computation when changing all nodes of a zone to gateway mode' (#937) from baptiste/garage:fix_layout_crash into main
Reviewed-on: Deuxfleurs/garage#937 Reviewed-by: Alex <lx@deuxfleurs.fr>
This commit is contained in:
commit
1cb0ae10a8
1 changed files with 10 additions and 4 deletions
|
@ -650,10 +650,13 @@ impl LayoutVersion {
|
||||||
let mut cost = CostFunction::new();
|
let mut cost = CostFunction::new();
|
||||||
for (p, assoc_p) in prev_assign.iter().enumerate() {
|
for (p, assoc_p) in prev_assign.iter().enumerate() {
|
||||||
for n in assoc_p.iter() {
|
for n in assoc_p.iter() {
|
||||||
let node_zone = zone_to_id[self.expect_get_node_zone(&self.node_id_vec[*n])];
|
if let Some(&node_zone) =
|
||||||
|
zone_to_id.get(self.expect_get_node_zone(&self.node_id_vec[*n]))
|
||||||
|
{
|
||||||
cost.insert((Vertex::PZ(p, node_zone), Vertex::N(*n)), -1);
|
cost.insert((Vertex::PZ(p, node_zone), Vertex::N(*n)), -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We compute the maximal length of a simple path in gflow. It is used in the
|
// We compute the maximal length of a simple path in gflow. It is used in the
|
||||||
// Bellman-Ford algorithm in optimize_flow_with_cost to set the number
|
// Bellman-Ford algorithm in optimize_flow_with_cost to set the number
|
||||||
|
@ -751,8 +754,11 @@ impl LayoutVersion {
|
||||||
if let Some(prev_assign) = prev_assign_opt {
|
if let Some(prev_assign) = prev_assign_opt {
|
||||||
let mut old_zones_of_p = Vec::<usize>::new();
|
let mut old_zones_of_p = Vec::<usize>::new();
|
||||||
for n in prev_assign[p].iter() {
|
for n in prev_assign[p].iter() {
|
||||||
old_zones_of_p
|
if let Some(&zone_id) =
|
||||||
.push(zone_to_id[self.expect_get_node_zone(&self.node_id_vec[*n])]);
|
zone_to_id.get(self.expect_get_node_zone(&self.node_id_vec[*n]))
|
||||||
|
{
|
||||||
|
old_zones_of_p.push(zone_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !old_zones_of_p.contains(&z) {
|
if !old_zones_of_p.contains(&z) {
|
||||||
new_partitions_zone[z] += 1;
|
new_partitions_zone[z] += 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue