Skip to content

Commit

Permalink
router: export names to info
Browse files Browse the repository at this point in the history
It's not good to show only uuid in info, when name identification is
used. Let's also show a name of a master and replicaset in such case.
We don't show master name for UUID identification, as it's not a
persisted name. We also don't replace uuid with names for name
identification in order to preserve backward compatibility of
vshard.storage.info().

Part of tarantool#426

@TarantoolBot document
Title: vshard: vshard.router.info shows name

When `identification_mode` is `name_as_key`, persisted master and
replicaset name is shown in vshard.router.info:

```
tarantool> vshard.router.info()
---
- replicasets:
    replicaset_1:
      replica: &0
        network_timeout: 0.5
        status: available
        uri: storage@127.0.0.1:3303
        name: replica_1_a
      name: replicaset_1
      master: *0
```
  • Loading branch information
Serpentian committed Dec 6, 2023
1 parent 234d824 commit f54c07e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 25 deletions.
24 changes: 12 additions & 12 deletions test/failover/cluster_changes.result
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,34 @@ vshard.router.info()
status: missing
bucket:
available_rw: 0
uuid: 971279ef-5c38-4d14-86ee-0e4a56567955
master:
network_timeout: 0.5
status: available
uri: storage@127.0.0.1:3309
uuid: 7171703a-fec2-45c9-beac-9a8aa40dcf85
uuid: 971279ef-5c38-4d14-86ee-0e4a56567955
739fe4fb-2850-4cde-9637-10150724c5eb:
replica:
status: missing
bucket:
available_rw: 0
uuid: 739fe4fb-2850-4cde-9637-10150724c5eb
master:
network_timeout: 0.5
status: available
uri: storage@127.0.0.1:3301
uuid: 3e01062d-5c1b-4382-b14e-f80a517cb462
uuid: 739fe4fb-2850-4cde-9637-10150724c5eb
832bbba0-9699-4aa1-907d-c7c7af61f5c9:
replica:
status: missing
bucket:
available_rw: 0
uuid: 832bbba0-9699-4aa1-907d-c7c7af61f5c9
master:
network_timeout: 0.5
status: available
uri: storage@127.0.0.1:3305
uuid: 27ef9a48-86f3-4759-89be-17aeaf4bd6ba
uuid: 832bbba0-9699-4aa1-907d-c7c7af61f5c9
bucket:
unreachable: 0
available_ro: 0
Expand Down Expand Up @@ -135,12 +135,12 @@ vshard.router.info()
uuid: dbcf1aaa-4e50-4753-bf06-aaba76297624
bucket:
available_rw: 0
uuid: 971279ef-5c38-4d14-86ee-0e4a56567955
master:
network_timeout: 0.5
status: available
uri: storage@127.0.0.1:3309
uuid: 7171703a-fec2-45c9-beac-9a8aa40dcf85
uuid: 971279ef-5c38-4d14-86ee-0e4a56567955
739fe4fb-2850-4cde-9637-10150724c5eb:
replica:
network_timeout: 0.5
Expand All @@ -149,12 +149,12 @@ vshard.router.info()
uuid: 56bb8450-9526-442b-ba96-b96cc38ee2f9
bucket:
available_rw: 0
uuid: 739fe4fb-2850-4cde-9637-10150724c5eb
master:
network_timeout: 0.5
status: available
uri: storage@127.0.0.1:3301
uuid: 3e01062d-5c1b-4382-b14e-f80a517cb462
uuid: 739fe4fb-2850-4cde-9637-10150724c5eb
832bbba0-9699-4aa1-907d-c7c7af61f5c9:
replica: &0
network_timeout: 0.5
Expand All @@ -163,8 +163,8 @@ vshard.router.info()
uuid: 27ef9a48-86f3-4759-89be-17aeaf4bd6ba
bucket:
available_rw: 0
uuid: 832bbba0-9699-4aa1-907d-c7c7af61f5c9
master: *0
uuid: 832bbba0-9699-4aa1-907d-c7c7af61f5c9
bucket:
unreachable: 0
available_ro: 0
Expand Down Expand Up @@ -291,8 +291,8 @@ info
status: missing
bucket:
unreachable: 0
uuid: 971279ef-5c38-4d14-86ee-0e4a56567955
master: *0
uuid: 971279ef-5c38-4d14-86ee-0e4a56567955
739fe4fb-2850-4cde-9637-10150724c5eb:
replica:
network_timeout: 0.5
Expand All @@ -301,9 +301,9 @@ info
uuid: 56bb8450-9526-442b-ba96-b96cc38ee2f9
bucket:
available_ro: 0
uuid: 739fe4fb-2850-4cde-9637-10150724c5eb
master:
status: missing
uuid: 739fe4fb-2850-4cde-9637-10150724c5eb
832bbba0-9699-4aa1-907d-c7c7af61f5c9:
replica:
network_timeout: 0.5
Expand All @@ -312,9 +312,9 @@ info
uuid: e2ed64b7-5c3a-4878-9ced-b71a034bd67f
bucket:
available_ro: 0
uuid: 832bbba0-9699-4aa1-907d-c7c7af61f5c9
master:
status: missing
uuid: 832bbba0-9699-4aa1-907d-c7c7af61f5c9
bucket:
unreachable: 0
available_ro: 0
Expand Down Expand Up @@ -391,12 +391,12 @@ vshard.router.info()
uuid: dbcf1aaa-4e50-4753-bf06-aaba76297624
bucket:
available_rw: 0
uuid: 971279ef-5c38-4d14-86ee-0e4a56567955
master:
network_timeout: 0.5
status: available
uri: storage@127.0.0.1:3309
uuid: 7171703a-fec2-45c9-beac-9a8aa40dcf85
uuid: 971279ef-5c38-4d14-86ee-0e4a56567955
739fe4fb-2850-4cde-9637-10150724c5eb:
replica:
network_timeout: 0.5
Expand All @@ -405,12 +405,12 @@ vshard.router.info()
uuid: 56bb8450-9526-442b-ba96-b96cc38ee2f9
bucket:
available_rw: 0
uuid: 739fe4fb-2850-4cde-9637-10150724c5eb
master:
network_timeout: 0.5
status: available
uri: storage@127.0.0.1:3301
uuid: 3e01062d-5c1b-4382-b14e-f80a517cb462
uuid: 739fe4fb-2850-4cde-9637-10150724c5eb
832bbba0-9699-4aa1-907d-c7c7af61f5c9:
replica: &0
network_timeout: 0.5
Expand All @@ -419,8 +419,8 @@ vshard.router.info()
uuid: 27ef9a48-86f3-4759-89be-17aeaf4bd6ba
bucket:
available_rw: 0
uuid: 832bbba0-9699-4aa1-907d-c7c7af61f5c9
master: *0
uuid: 832bbba0-9699-4aa1-907d-c7c7af61f5c9
bucket:
unreachable: 0
available_ro: 0
Expand Down
8 changes: 4 additions & 4 deletions test/rebalancer/restart_during_rebalancing.result
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ info
uuid: <fullbox_1_a>
bucket:
available_rw: number
uuid: <replicaset_1>
master: *0
uuid: <replicaset_1>
<replicaset_4>:
replica: &1
network_timeout: number
Expand All @@ -256,8 +256,8 @@ info
uuid: <box_4_a>
bucket:
available_rw: number
uuid: <replicaset_4>
master: *1
uuid: <replicaset_4>
<replicaset_2>:
replica: &2
network_timeout: number
Expand All @@ -266,8 +266,8 @@ info
uuid: <box_2_a>
bucket:
available_rw: number
uuid: <replicaset_2>
master: *2
uuid: <replicaset_2>
<replicaset_3>:
replica: &3
network_timeout: number
Expand All @@ -276,8 +276,8 @@ info
uuid: <box_3_a>
bucket:
available_rw: number
uuid: <replicaset_3>
master: *3
uuid: <replicaset_3>
bucket:
unreachable: 0
available_ro: 0
Expand Down
5 changes: 5 additions & 0 deletions test/router-luatest/router_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,11 @@ g.test_named_config_identification = function(g)
local _, err = ivshard.router.bucket_discovery(1)
ilt.assert_equals(err, nil)
ilt.assert_not_equals(ivshard.router.buckets_info()[1].name, nil)
-- vshard.router.info() also shows names.
local rs = ivshard.router.info().replicasets['replicaset_1']
ilt.assert_equals(rs.name, 'replicaset_1')
ilt.assert_equals(rs.master.name, 'replica_1_a')

-- just basic test
return ivshard.router.callrw(1, 'echo', {1}, {timeout = iwait_timeout})
end)
Expand Down
4 changes: 2 additions & 2 deletions test/router/reconnect_to_master.result
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ vshard.router.info()
uuid: 1e02ae8a-afc0-4e91-ba34-843a356b8ed7
bucket:
available_rw: 0
uuid: ac522f65-aa94-4134-9f64-51ee384f1a54
master: *0
uuid: ac522f65-aa94-4134-9f64-51ee384f1a54
cbf06940-0790-498b-948d-042b62cf3d29:
replica:
network_timeout: 0.5
Expand All @@ -136,12 +136,12 @@ vshard.router.info()
uuid: 3de2e3e1-9ebe-4d0d-abb1-26d301b84633
bucket:
available_ro: 10
uuid: cbf06940-0790-498b-948d-042b62cf3d29
master:
network_timeout: 0.5
status: unreachable
uri: storage@127.0.0.1:3301
uuid: 8a274925-a26d-47fc-9e1b-af88ce939412
uuid: cbf06940-0790-498b-948d-042b62cf3d29
bucket:
unreachable: 0
available_ro: 10
Expand Down
12 changes: 6 additions & 6 deletions test/router/router.result
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ vshard.router.info()
uuid: <storage_2_a>
bucket:
available_rw: 1
uuid: <replicaset_2>
master: *0
uuid: <replicaset_2>
<replicaset_1>:
replica: &1
network_timeout: 0.5
Expand All @@ -211,8 +211,8 @@ vshard.router.info()
uuid: <storage_1_a>
bucket:
available_rw: 0
uuid: <replicaset_1>
master: *1
uuid: <replicaset_1>
bucket:
unreachable: 0
available_ro: 0
Expand Down Expand Up @@ -1053,8 +1053,8 @@ info
uuid: <storage_2_a>
bucket:
available_rw: 1500
uuid: <replicaset_2>
master: *0
uuid: <replicaset_2>
<replicaset_1>:
replica: &1
network_timeout: 0.5
Expand All @@ -1063,8 +1063,8 @@ info
uuid: <storage_1_a>
bucket:
available_rw: 1500
uuid: <replicaset_1>
master: *1
uuid: <replicaset_1>
bucket:
unreachable: 0
available_ro: 0
Expand Down Expand Up @@ -1102,8 +1102,8 @@ info.replicasets[rs.uuid]
uuid: <storage_1_a>
bucket:
unreachable: 1500
uuid: <replicaset_1>
master: *0
uuid: <replicaset_1>
...
info.status
---
Expand Down Expand Up @@ -1140,9 +1140,9 @@ info.replicasets[rs.uuid]
uuid: <storage_1_a>
bucket:
available_ro: 1500
uuid: <replicaset_1>
master:
status: missing
uuid: <replicaset_1>
...
info.status
---
Expand Down
7 changes: 6 additions & 1 deletion vshard/router/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,10 @@ local function replicaset_instance_info(replicaset, name, alerts, errcolor,
local info = {}
local replica = replicaset[name]
if replica then
local is_named = replica.id == replica.name
info.uri = replica:safe_uri()
info.uuid = replica.uuid
info.name = is_named and replica.name or nil
info.network_timeout = replica.net_timeout
if replica:is_connected() then
info.status = 'available'
Expand Down Expand Up @@ -1466,17 +1468,20 @@ local function router_info(router, opts)
-- Replicaset info parameters:
-- * master instance info;
-- * replica instance info;
-- * replicaset uuid.
-- * replicaset uuid;
-- * replicaset name (only for named identification).
--
-- Instance info parameters:
-- * uri;
-- * uuid;
-- * name (only for named identification);
-- * status - available, unreachable, missing;
-- * network_timeout - timeout for requests, updated on
-- each 10 success and 2 failed requests. The greater
-- timeout, the worse network feels itself.
local rs_info = {
uuid = replicaset.uuid,
name = replicaset.name,
bucket = {}
}
state.replicasets[replicaset.id] = rs_info
Expand Down

0 comments on commit f54c07e

Please sign in to comment.