mirror of
https://git.deuxfleurs.fr/Deuxfleurs/garage.git
synced 2024-12-18 13:16:46 +00:00
Merge pull request 'Filter nodes Garage tries to connect to' (#719) from reconnect-only-current into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/719
This commit is contained in:
commit
203bb10035
1 changed files with 16 additions and 5 deletions
|
@ -728,15 +728,18 @@ impl System {
|
||||||
|
|
||||||
async fn discovery_loop(self: &Arc<Self>, mut stop_signal: watch::Receiver<bool>) {
|
async fn discovery_loop(self: &Arc<Self>, mut stop_signal: watch::Receiver<bool>) {
|
||||||
while !*stop_signal.borrow() {
|
while !*stop_signal.borrow() {
|
||||||
let not_configured = self.ring.borrow().layout.check().is_err();
|
let n_connected = self
|
||||||
let no_peers = self.peering.get_peer_list().len() < self.replication_factor;
|
|
||||||
let expected_n_nodes = self.ring.borrow().layout.num_nodes();
|
|
||||||
let bad_peers = self
|
|
||||||
.peering
|
.peering
|
||||||
.get_peer_list()
|
.get_peer_list()
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|p| p.is_up())
|
.filter(|p| p.is_up())
|
||||||
.count() != expected_n_nodes;
|
.count();
|
||||||
|
|
||||||
|
let not_configured = self.ring.borrow().layout.check().is_err();
|
||||||
|
let no_peers = n_connected < self.replication_factor;
|
||||||
|
|
||||||
|
let expected_n_nodes = self.ring.borrow().layout.num_nodes();
|
||||||
|
let bad_peers = n_connected != expected_n_nodes;
|
||||||
|
|
||||||
if not_configured || no_peers || bad_peers {
|
if not_configured || no_peers || bad_peers {
|
||||||
info!("Doing a bootstrap/discovery step (not_configured: {}, no_peers: {}, bad_peers: {})", not_configured, no_peers, bad_peers);
|
info!("Doing a bootstrap/discovery step (not_configured: {}, no_peers: {}, bad_peers: {})", not_configured, no_peers, bad_peers);
|
||||||
|
@ -783,6 +786,14 @@ impl System {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !not_configured && !no_peers {
|
||||||
|
// If the layout is configured, and we already have some connections
|
||||||
|
// to other nodes in the cluster, we can skip trying to connect to
|
||||||
|
// nodes that are not in the cluster layout.
|
||||||
|
let ring = self.ring.borrow();
|
||||||
|
ping_list.retain(|(id, _)| ring.layout.node_ids().contains(&(*id).into()));
|
||||||
|
}
|
||||||
|
|
||||||
for (node_id, node_addr) in ping_list {
|
for (node_id, node_addr) in ping_list {
|
||||||
let self2 = self.clone();
|
let self2 = self.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
|
Loading…
Reference in a new issue