@@ -4,18 +4,48 @@ local vshard = require('vshard')
44
55local vshard_utils = {}
66
7+ -- get_replicasets returns vshard replicasets from vshard.storage.internal
8+ -- copy pasted from https://github.com/tarantool/vshard/blob/9ad0e2726a5137398f50fe88ac105f53e446c3e2/vshard/storage/init.lua#L3962-L3984
9+ -- todo: remove after https://github.com/tarantool/vshard/issues/565 closed
10+ local function get_replicasets ()
11+ local ireplicasets = {}
12+ local M = vshard .storage .internal
13+ local is_named = M .this_replica .id == M .this_replica .name
14+ for id , replicaset in pairs (M .replicasets ) do
15+ local master = replicaset .master
16+ local master_info
17+ if replicaset .is_master_auto then
18+ master_info = ' auto'
19+ elseif not master then
20+ master_info = ' missing'
21+ else
22+ local uri = master :safe_uri ()
23+ local conn = master .conn
24+ master_info = {
25+ uri = uri , uuid = conn and conn .peer_uuid ,
26+ name = is_named and master .name or nil ,
27+ state = conn and conn .state , error = conn and conn .error ,
28+ }
29+ end
30+ ireplicasets [id ] = {
31+ uuid = replicaset .uuid ,
32+ name = is_named and replicaset .name or nil ,
33+ master = master_info ,
34+ }
35+ end
36+ return ireplicasets
37+ end
38+
739function vshard_utils .get_self_vshard_replicaset ()
840 local box_info = vshard_utils .__get_box_info ()
941
1042 local ok , storage_info = vshard_utils .__get_storage_info ()
1143 assert (ok , ' vshard.storage.cfg() must be called first' )
1244
13-
1445 local is_needs_upgrade_2_11 = vshard_utils .is_schema_needs_upgrade_from_2_11 ()
1546
1647 if vshard_utils .get_vshard_identification_mode () == ' name_as_key' and not is_needs_upgrade_2_11 then
1748 local replicaset_name = box_info .replicaset .name
18-
1949 return replicaset_name , storage_info .replicasets [replicaset_name ]
2050 else
2151 local replicaset_uuid
3666
3767-- for unit tests
3868function vshard_utils .__get_storage_info ()
69+ -- cartridge disable vshard.storage on the very first apply_config
70+ -- here we check this and do not call vshard.storage.info
71+ -- todo: remove after https://github.com/tarantool/vshard/issues/565 closed
72+ if vshard .storage .internal .is_enabled == false then
73+ return true , {
74+ replicasets = get_replicasets (),
75+ }
76+ end
3977 return pcall (vshard .storage .info )
4078end
4179
0 commit comments