From 8248bc4935b60bcaecd6899a3cc9e766e65ddcd3 Mon Sep 17 00:00:00 2001 From: Igor Zolotarev <63460867+yngvar-antonsson@users.noreply.github.com> Date: Wed, 5 Apr 2023 17:10:11 +0400 Subject: [PATCH] Allow to promote instances without electable configuration (#2062) --- cartridge/roles/coordinator.lua | 2 +- test/integration/electable_test.lua | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cartridge/roles/coordinator.lua b/cartridge/roles/coordinator.lua index c46e187a3..16f7753e6 100644 --- a/cartridge/roles/coordinator.lua +++ b/cartridge/roles/coordinator.lua @@ -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 diff --git a/test/integration/electable_test.lua b/test/integration/electable_test.lua index fe3df9f51..71fbdf979 100644 --- a/test/integration/electable_test.lua +++ b/test/integration/electable_test.lua @@ -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)