Skip to content

Commit

Permalink
Allow to promote instances without electable configuration (#2062)
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvar-antonsson authored Apr 5, 2023
1 parent facf35b commit 8248bc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cartridge/roles/coordinator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ local function appoint_leaders(leaders)

local updates = {}
for replicaset_uuid, leader_uuid in pairs(leaders) do
if not servers[leader_uuid].electable then
if servers[leader_uuid].electable == false then
return nil, AppointmentError:new("Cannot appoint non-electable instance")
end

Expand Down
14 changes: 14 additions & 0 deletions test/integration/electable_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,17 @@ add('test_set_electable', function(g)
end)
end)

add('test_last_instance_electable', function(g)
g.cluster:server("core-1"):exec(function(uuid)
local vars = require('cartridge.vars').new('cartridge.roles.coordinator')
vars.topology_cfg.servers[uuid].electable = nil -- pretend that instance doesn't have electable field

return vars.topology_cfg.servers[uuid]
end, {storage1_2_uuid})

local _, err = g.cluster.main_server:eval(q_promote, { { [storage1_uuid] = storage1_2_uuid } })

t.assert_not(err)

t.assert(g.cluster:server('storage-1-replica-1'):exec(is_leader))
end)

0 comments on commit 8248bc4

Please sign in to comment.