diff options
author | Alex <alex@adnab.me> | 2024-02-20 10:37:11 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2024-02-20 10:37:11 +0000 |
commit | 203bb10035dd3e350d89141f6ed917733c45e0f8 (patch) | |
tree | f463aadc74075fb665f27643c29e30a7111a0bdc | |
parent | 0b9859befa80f0524da2c2ad121105e6263f8a33 (diff) | |
parent | e91576677e712c07cf9c47b1a0d2cc4d2d1d37cf (diff) | |
download | garage-203bb10035dd3e350d89141f6ed917733c45e0f8.tar.gz garage-203bb10035dd3e350d89141f6ed917733c45e0f8.zip |
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
-rw-r--r-- | src/rpc/system.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/rpc/system.rs b/src/rpc/system.rs index 147ec4d6..998517de 100644 --- a/src/rpc/system.rs +++ b/src/rpc/system.rs @@ -728,15 +728,18 @@ impl System { async fn discovery_loop(self: &Arc<Self>, mut stop_signal: watch::Receiver<bool>) { while !*stop_signal.borrow() { - let not_configured = self.ring.borrow().layout.check().is_err(); - 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 + let n_connected = self .peering .get_peer_list() .iter() .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 { 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 { let self2 = self.clone(); tokio::spawn(async move { |