From 398bec5cb4bd3f5f3b3a5317c5b938ef892afab7 Mon Sep 17 00:00:00 2001 From: Phoeniix Zhao Date: Sun, 25 Feb 2024 12:44:11 +0800 Subject: [PATCH] fix: add client urls for new added node's publish progress Signed-off-by: Phoeniix Zhao --- crates/curp/src/members.rs | 4 ++++ crates/curp/tests/it/common/curp_group.rs | 3 ++- doc/QUICK_START.md | 16 ++++++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/crates/curp/src/members.rs b/crates/curp/src/members.rs index f56aa5349..90d730854 100644 --- a/crates/curp/src/members.rs +++ b/crates/curp/src/members.rs @@ -138,6 +138,7 @@ impl ClusterInfo { pub fn from_cluster( cluster: FetchClusterResponse, self_peer_urls: &[String], + self_client_urls: &[String], self_name: &str, ) -> Self { let mut member_id = 0; @@ -149,6 +150,7 @@ impl ClusterInfo { if sorted_self_addr == member.peer_urls() { member_id = member.id; member.name = self_name.to_owned(); + member.client_urls = self_client_urls.to_vec(); } (member.id, member) }) @@ -424,6 +426,7 @@ pub async fn get_cluster_info_from_remote( tls_config: Option<&ClientTlsConfig>, ) -> Option { let peers = init_cluster_info.peers_addrs(); + let self_client_urls = init_cluster_info.self_client_urls(); let connects = rpc::connects(peers, tls_config) .await .ok()? @@ -446,6 +449,7 @@ pub async fn get_cluster_info_from_remote( return Some(ClusterInfo::from_cluster( cluster_res.into_inner(), self_peer_urls, + self_client_urls.as_slice(), self_name, )); } diff --git a/crates/curp/tests/it/common/curp_group.rs b/crates/curp/tests/it/common/curp_group.rs index 0a12cff6a..6ff65df04 100644 --- a/crates/curp/tests/it/common/curp_group.rs +++ b/crates/curp/tests/it/common/curp_group.rs @@ -492,6 +492,7 @@ impl CurpGroup { pub async fn fetch_cluster_info(&self, addrs: &[String], name: &str) -> ClusterInfo { let leader_id = self.get_leader().await.0; let mut connect = self.get_connect(&leader_id).await; + let client_urls: Vec = vec![]; let cluster_res_base = connect .fetch_cluster(tonic::Request::new(FetchClusterRequest { linearizable: false, @@ -511,7 +512,7 @@ impl CurpGroup { members, cluster_version: cluster_res_base.cluster_version, }; - ClusterInfo::from_cluster(cluster_res, addrs, name) + ClusterInfo::from_cluster(cluster_res, addrs, client_urls.as_slice(), name) } } diff --git a/doc/QUICK_START.md b/doc/QUICK_START.md index 171c78668..1deac48b0 100644 --- a/doc/QUICK_START.md +++ b/doc/QUICK_START.md @@ -158,14 +158,14 @@ $ docker exec -e RUST_LOG=debug -d node4 /usr/local/bin/xline --name node4 --mem # check whether the new member adding success or not $ docker exec client /bin/sh -c "/usr/local/bin/etcdctl --endpoints=\"http://172.20.0.3:2379\" member list -w table" -+------------------+---------+-------+-------------------------------------------------+------------------------+------------+ -| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER | -+------------------+---------+-------+-------------------------------------------------+------------------------+------------+ -| f724bbce9f9988f6 | started | node1 | 172.20.0.3:2380,172.20.0.3:2381 | http://172.20.0.3:2379 | false | -| 2bd3a73819298fd6 | started | node2 | 172.20.0.4:2380,172.20.0.4:2381 | http://172.20.0.4:2379 | false | -| e17dd71c0e2c6d1e | started | node3 | 172.20.0.5:2380,172.20.0.5:2381 | http://172.20.0.5:2379 | false | -| 343900f0eec03419 | started | node4 | http://172.20.0.17:2380,http://172.20.0.17:2381 | http://172.20.0.17:2379| false | -+------------------+---------+-------+-------------------------------------------------+------------------------+------------+ ++------------------+---------+-------+-------------------------------------------------+-------------------------+------------+ +| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER | ++------------------+---------+-------+-------------------------------------------------+-------------------------+------------+ +| f724bbce9f9988f6 | started | node1 | 172.20.0.3:2380,172.20.0.3:2381 | http://172.20.0.3:2379 | false | +| 2bd3a73819298fd6 | started | node2 | 172.20.0.4:2380,172.20.0.4:2381 | http://172.20.0.4:2379 | false | +| e17dd71c0e2c6d1e | started | node3 | 172.20.0.5:2380,172.20.0.5:2381 | http://172.20.0.5:2379 | false | +| 343900f0eec03419 | started | node4 | http://172.20.0.17:2380,http://172.20.0.17:2381 | http://172.20.0.17:2379 | false | ++------------------+---------+-------+-------------------------------------------------+-------------------------+------------+ # do the member remove $ docker exec client /bin/sh -c "/usr/local/bin/etcdctl --endpoints=\"http://172.20.0.3:2379\" member remove 343900f0eec03419"