Skip to content

Commit

Permalink
storage: export name to info
Browse files Browse the repository at this point in the history
When named config is used, there may be no UUIDs specified for
replicas and replicasets. Consequently, in such case we must
also show the names in addition to UUIDs in storage.info().

Part of #426

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

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

```
tarantool> vshard.storage.info()
---
- replicasets:
    replicaset_1:
      name: replicaset_1
      master:
        uri: admin@localhost:3302
        name: replica_1_a
  ...
```
  • Loading branch information
Serpentian authored and Gerold103 committed Dec 19, 2023
1 parent 4c9cc51 commit 559c75c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
10 changes: 10 additions & 0 deletions test/storage-luatest/storage_1_1_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ test_group.test_named_config_identification = function(g)

-- Attempt to configure with named config without name set causes error.
g.replica_1_a:exec(function(cfg)
-- Name is not shown in info, when uuid identification is used.
local rs = ivshard.storage.info().replicasets[ivutil.replicaset_uuid()]
ilt.assert_equals(rs.name, nil)
ilt.assert_equals(rs.master.name, nil)
ilt.assert_error_msg_contains('Instance name mismatch',
ivshard.storage.cfg, cfg, 'replica_1_a')
end, {new_global_cfg})
Expand Down Expand Up @@ -574,6 +578,12 @@ test_group.test_named_config_identification = function(g)
local rs_name_2 = g.replica_2_a:replicaset_name()
t.assert_equals(rs_name_2, 'replicaset_2')
local bid = g.replica_1_a:exec(function(name)
-- Name is shown, when name identification is used.
local rs = ivshard.storage.info().replicasets[box.info.replicaset.name]
ilt.assert_equals(rs.name, box.info.replicaset.name)
ilt.assert_equals(rs.uuid, nil)
ilt.assert_equals(rs.master.name, box.info.name)

local bid = _G.get_first_bucket()
local ok, err = ivshard.storage.bucket_send(
bid, name, {timeout = _G.iwait_timeout})
Expand Down
44 changes: 22 additions & 22 deletions test/storage/storage.result
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ _ = test_run:switch('storage_1_a')
...
vshard.storage.info().replicasets[util.replicasets[1]] or vshard.storage.info()
---
- uuid: <replicaset_1>
master:
- master:
uri: storage@127.0.0.1:3301
uuid: <replicaset_1>
...
vshard.storage.info().replicasets[util.replicasets[2]] or vshard.storage.info()
---
- uuid: <replicaset_2>
master:
- master:
uri: storage@127.0.0.1:3303
uuid: <replicaset_2>
...
-- Try to call info on a replicaset with no master.
rs1 = vshard.storage.internal.replicasets[util.replicasets[1]]
Expand All @@ -137,12 +137,12 @@ vshard.storage.info()
---
- replicasets:
<replicaset_2>:
uuid: <replicaset_2>
master:
uri: storage@127.0.0.1:3303
uuid: <replicaset_2>
<replicaset_1>:
uuid: <replicaset_1>
master: missing
uuid: <replicaset_1>
bucket:
receiving: 0
active: 0
Expand Down Expand Up @@ -257,13 +257,13 @@ vshard.storage.info()
---
- replicasets:
<replicaset_2>:
uuid: <replicaset_2>
master:
uri: storage@127.0.0.1:3303
uuid: <replicaset_2>
<replicaset_1>:
uuid: <replicaset_1>
master:
uri: storage@127.0.0.1:3301
uuid: <replicaset_1>
bucket:
receiving: 0
active: 2
Expand Down Expand Up @@ -313,17 +313,17 @@ info
---
- replicasets:
<replicaset_2>:
uuid: <replicaset_2>
master:
state: active
uri: storage@127.0.0.1:3303
state: active
uuid: <storage_2_a>
uuid: <replicaset_2>
<replicaset_1>:
uuid: <replicaset_1>
master:
state: active
uri: storage@127.0.0.1:3301
state: active
uuid: <storage_1_a>
uuid: <replicaset_1>
bucket:
receiving: 0
active: 2
Expand All @@ -343,17 +343,17 @@ vshard.storage.info()
---
- replicasets:
<replicaset_2>:
uuid: <replicaset_2>
master:
state: active
uri: storage@127.0.0.1:3303
state: active
uuid: <storage_2_a>
uuid: <replicaset_2>
<replicaset_1>:
uuid: <replicaset_1>
master:
state: active
uri: storage@127.0.0.1:3301
state: active
uuid: <storage_1_a>
uuid: <replicaset_1>
bucket:
receiving: 0
active: 2
Expand All @@ -378,13 +378,13 @@ vshard.storage.info()
---
- replicasets:
<replicaset_2>:
uuid: <replicaset_2>
master:
uri: storage@127.0.0.1:3303
uuid: <replicaset_2>
<replicaset_1>:
uuid: <replicaset_1>
master:
uri: storage@127.0.0.1:3301
uuid: <replicaset_1>
bucket:
receiving: 0
active: 2
Expand All @@ -405,17 +405,17 @@ vshard.storage.info()
---
- replicasets:
<replicaset_2>:
uuid: <replicaset_2>
master:
state: active
uri: storage@127.0.0.1:3303
state: active
uuid: <storage_2_a>
uuid: <replicaset_2>
<replicaset_1>:
uuid: <replicaset_1>
master:
state: active
uri: storage@127.0.0.1:3301
state: active
uuid: <storage_1_a>
uuid: <replicaset_1>
bucket:
receiving: 0
active: 2
Expand Down
2 changes: 2 additions & 0 deletions vshard/storage/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3876,11 +3876,13 @@ local function storage_info(opts)
local conn = master.conn
master_info = {
uri = uri, uuid = conn and conn.peer_uuid,
name = is_named and master.name or nil,
state = conn and conn.state, error = conn and conn.error,
}
end
ireplicasets[id] = {
uuid = replicaset.uuid,
name = is_named and replicaset.name or nil,
master = master_info,
}
end
Expand Down

0 comments on commit 559c75c

Please sign in to comment.