Skip to content

Commit

Permalink
Fix expel of the last vshard instance
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvar-antonsson committed Jul 3, 2024
1 parent 6f079b4 commit ab31a0b
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 9 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ and this project adheres to
Unreleased
-------------------------------------------------------------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Added
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- VShard alerts are displayed in issues list.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Last instance in vshard-storage replicaset can be expelled now.

-------------------------------------------------------------------------------
[2.12.2] - 2024-06-24
-------------------------------------------------------------------------------
Expand Down
20 changes: 19 additions & 1 deletion cartridge/roles/vshard-router.lua
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,21 @@ local function bootstrap()
return true
end

local function get_issues()
local issues = table.deepcopy(vars.issues)
if vshard.router.info == nil then
return issues
end
for _, alert in ipairs(vshard.router.info().alerts) do
table.insert(issues, {
level = 'warning',
topic = 'vshard',
message = alert[2],
})
end
return issues
end

return {
role_name = 'vshard-router',
implies_router = true,
Expand All @@ -299,8 +314,11 @@ return {
validate_config = vshard_utils.validate_config,
apply_config = apply_config,
stop = stop,
get_issues = function() return vars.issues end,
get_issues = get_issues,

get = get,
bootstrap = bootstrap,
get_alerts = function()
return vshard and vshard.router and vshard.router.info and vshard.router.info().alerts or {}
end,
}
17 changes: 16 additions & 1 deletion cartridge/roles/vshard-storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ local function stop()
_G_vshard_backup = nil
end

local function get_issues()
local issues = table.deepcopy(vars.issues)
if vshard.storage.info == nil then
return issues
end
for _, alert in ipairs(vshard.storage.info().alerts) do
table.insert(issues, {
level = 'warning',
topic = 'vshard',
message = alert[2],
})
end
return issues
end

return {
role_name = 'vshard-storage',
implies_storage = true,
Expand All @@ -117,5 +132,5 @@ return {
on_apply_config = on_apply_config,
init = init,
stop = stop,
get_issues = function() return vars.issues end,
get_issues = get_issues,
}
28 changes: 21 additions & 7 deletions cartridge/vshard-utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local topology = require('cartridge.topology')
local failover = require('cartridge.failover')
local twophase = require('cartridge.twophase')
local confapplier = require('cartridge.confapplier')
local rpc = require('cartridge.rpc')

local ok, vshard_consts = pcall(require, 'vshard-ee.consts')
if not ok then
Expand Down Expand Up @@ -152,14 +153,27 @@ local function validate_group_upgrade(group_name, topology_new, topology_old)
)

if buckets_count == nil then
error(err)
end

ValidateConfigError:assert(
buckets_count == 0,
"replicasets[%s] rebalancing isn't finished yet",
replicaset_uuid
)
-- vshard storage is probably off
-- so we need to call a router to get the alerts
local alerts, call_err = rpc.call('vshard-router', 'get_alerts')
if alerts == nil then
error(call_err)
end
for _, alert in ipairs(alerts) do
if alert[1] == 'UNKNOWN_BUCKETS' then
error(alert[2] ..
'. Please make sure that all buckets are safe ' ..
'before making any changes')
end
end
else
ValidateConfigError:assert(
buckets_count == 0,
"replicasets[%s] rebalancing isn't finished yet",
replicaset_uuid
)
end
end

end
Expand Down

0 comments on commit ab31a0b

Please sign in to comment.