Skip to content

Commit

Permalink
fix: add client urls for new added node's publish progress
Browse files Browse the repository at this point in the history
Signed-off-by: Phoeniix Zhao <[email protected]>
  • Loading branch information
Phoenix500526 committed May 20, 2024
1 parent 9ee85b1 commit 4a62349
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions crates/curp/src/members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
})
Expand Down Expand Up @@ -424,6 +426,7 @@ pub async fn get_cluster_info_from_remote(
tls_config: Option<&ClientTlsConfig>,
) -> Option<ClusterInfo> {
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()?
Expand All @@ -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,
));
}
Expand Down
3 changes: 2 additions & 1 deletion crates/curp/tests/it/common/curp_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,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<String> = vec![];
let cluster_res_base = connect
.fetch_cluster(tonic::Request::new(FetchClusterRequest {
linearizable: false,
Expand All @@ -461,7 +462,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)
}
}

Expand Down
16 changes: 8 additions & 8 deletions doc/QUICK_START.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4a62349

Please sign in to comment.