Skip to content

Commit

Permalink
node: check that at least one replica for each shard has a non-zero w…
Browse files Browse the repository at this point in the history
…eight
  • Loading branch information
lutter committed Aug 25, 2021
1 parent 55cebe4 commit 2d7dc36
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ impl Shard {
validate_name(name).context("illegal replica name")?;
replica.validate(&self.pool_size)?;
}

let no_weight =
self.weight == 0 && self.replicas.values().all(|replica| replica.weight == 0);
if no_weight {
return Err(anyhow!(
"all weights for shard `{}` are 0; \
remove explicit weights or set at least one of them to a value bigger than 0",
name
));
}
Ok(())
}

Expand Down

0 comments on commit 2d7dc36

Please sign in to comment.