From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: tarantool-patches@dev.tarantool.org, olegrok@tarantool.org, yaroslav.dynnikov@tarantool.org Subject: [Tarantool-patches] [PATCH vshard 4/6] config: introduce master 'auto' replicaset option Date: Fri, 2 Jul 2021 00:09:34 +0200 [thread overview] Message-ID: <888cee3d83fff78411e0cf96ee6b2e8292887677.1625177221.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1625177221.git.v.shpilevoy@tarantool.org> The new option will enable auto-search for master on the marked replicasets. Part of #75 --- test/unit/config.result | 48 +++++++++++++++++++++++++++++++++++++++ test/unit/config.test.lua | 21 +++++++++++++++++ vshard/cfg.lua | 27 +++++++++++++++++++--- 3 files changed, 93 insertions(+), 3 deletions(-) diff --git a/test/unit/config.result b/test/unit/config.result index 9df3bf1..676ee4d 100644 --- a/test/unit/config.result +++ b/test/unit/config.result @@ -656,3 +656,51 @@ util.check_error(lcfg.check, cfg) cfg.sched_move_quota = nil --- ... +-- +-- gh-75: auto master discovery. +-- +replicaset = {replicas = {uuid = replica}} +--- +... +replicaset.master = 'auto' +--- +... +cfg.sharding = {rsid = replicaset} +--- +... +_ = lcfg.check(cfg) +--- +... +replicaset.master = 'non-auto' +--- +... +util.check_error(lcfg.check, cfg) +--- +- Only "auto" master is supported +... +replicaset.master = 123 +--- +... +util.check_error(lcfg.check, cfg) +--- +- Master search mode must be string +... +replica.master = true +--- +... +replicaset.master = 'auto' +--- +... +util.check_error(lcfg.check, cfg) +--- +- Can not specify master nodes when master search is enabled, but found master flag + in replica uuid uuid +... +replica.master = false +--- +... +util.check_error(lcfg.check, cfg) +--- +- Can not specify master nodes when master search is enabled, but found master flag + in replica uuid uuid +... diff --git a/test/unit/config.test.lua b/test/unit/config.test.lua index 473e460..4dfbd77 100644 --- a/test/unit/config.test.lua +++ b/test/unit/config.test.lua @@ -264,3 +264,24 @@ _ = lcfg.check(cfg) cfg.sched_move_quota = -1 util.check_error(lcfg.check, cfg) cfg.sched_move_quota = nil + +-- +-- gh-75: auto master discovery. +-- +replicaset = {replicas = {uuid = replica}} +replicaset.master = 'auto' +cfg.sharding = {rsid = replicaset} +_ = lcfg.check(cfg) + +replicaset.master = 'non-auto' +util.check_error(lcfg.check, cfg) + +replicaset.master = 123 +util.check_error(lcfg.check, cfg) + +replica.master = true +replicaset.master = 'auto' +util.check_error(lcfg.check, cfg) + +replica.master = false +util.check_error(lcfg.check, cfg) diff --git a/vshard/cfg.lua b/vshard/cfg.lua index 30f8794..401d969 100644 --- a/vshard/cfg.lua +++ b/vshard/cfg.lua @@ -2,6 +2,7 @@ local log = require('log') local luri = require('uri') +local lutil = require('vshard.util') local consts = require('vshard.consts') local function check_uri(uri) @@ -10,7 +11,7 @@ local function check_uri(uri) end end -local function check_master(master, ctx) +local function check_replica_master(master, ctx) if master then if ctx.master then error('Only one master is allowed per replicaset') @@ -20,6 +21,15 @@ local function check_master(master, ctx) end end +local function check_replicaset_master(master, ctx) + if not lutil.version_is_at_least(1, 10, 0) then + error('Only versions >= 1.10 support master discovery') + end + if master ~= 'auto' then + error('Only "auto" master is supported') + end +end + local function is_number(v) return type(v) == 'number' and v == v end @@ -111,8 +121,8 @@ local replica_template = { name = {type = 'string', name = "Name", is_optional = true}, zone = {type = {'string', 'number'}, name = "Zone", is_optional = true}, master = { - type = 'boolean', name = "Master", is_optional = true, default = false, - check = check_master + type = 'boolean', name = "Master", is_optional = true, + check = check_replica_master }, } @@ -130,6 +140,10 @@ local replicaset_template = { default = 1, }, lock = {type = 'boolean', name = 'Lock', is_optional = true}, + master = { + type = 'string', name = 'Master search mode', is_optional = true, + check = check_replicaset_master + }, } -- @@ -185,6 +199,7 @@ local function check_sharding(sharding) error('Replicaset weight can not be Inf') end validate_config(replicaset, replicaset_template) + local is_auto_master = replicaset.master == 'auto' for replica_uuid, replica in pairs(replicaset.replicas) do if uris[replica.uri] then error(string.format('Duplicate uri %s', replica.uri)) @@ -194,6 +209,12 @@ local function check_sharding(sharding) error(string.format('Duplicate uuid %s', replica_uuid)) end uuids[replica_uuid] = true + if is_auto_master and replica.master ~= nil then + error(string.format('Can not specify master nodes when '.. + 'master search is enabled, but found '.. + 'master flag in replica uuid %s', + replica_uuid)) + end -- Log warning in case replica.name duplicate is -- found. Message appears once for each unique -- duplicate. -- 2.24.3 (Apple Git-128)
next prev parent reply other threads:[~2021-07-01 22:11 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-01 22:09 [Tarantool-patches] [PATCH vshard 0/6] Master discovery Vladislav Shpilevoy via Tarantool-patches 2021-07-01 22:09 ` [Tarantool-patches] [PATCH vshard 1/6] replicaset: introduce netbox_wait_connected() Vladislav Shpilevoy via Tarantool-patches 2021-07-02 11:46 ` Oleg Babin via Tarantool-patches 2021-07-01 22:09 ` [Tarantool-patches] [PATCH vshard 2/6] test: sort some table prints Vladislav Shpilevoy via Tarantool-patches 2021-07-02 11:46 ` Oleg Babin via Tarantool-patches 2021-07-01 22:09 ` [Tarantool-patches] [PATCH vshard 3/6] storage: introduce vshard.storage._call('info') Vladislav Shpilevoy via Tarantool-patches 2021-07-02 11:46 ` Oleg Babin via Tarantool-patches 2021-07-01 22:09 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-07-02 11:47 ` [Tarantool-patches] [PATCH vshard 4/6] config: introduce master 'auto' replicaset option Oleg Babin via Tarantool-patches 2021-07-02 21:32 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-05 9:23 ` Oleg Babin via Tarantool-patches 2021-07-01 22:09 ` [Tarantool-patches] [PATCH vshard 5/6] router: introduce automatic master discovery Vladislav Shpilevoy via Tarantool-patches 2021-07-02 11:48 ` Oleg Babin via Tarantool-patches 2021-07-02 21:35 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-05 9:24 ` Oleg Babin via Tarantool-patches 2021-07-05 20:53 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-06 8:54 ` Oleg Babin via Tarantool-patches 2021-07-06 21:19 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-01 22:09 ` [Tarantool-patches] [PATCH vshard 6/6] router: update master using a hint from storage Vladislav Shpilevoy via Tarantool-patches 2021-07-02 11:49 ` Oleg Babin via Tarantool-patches 2021-07-02 21:36 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-05 9:24 ` Oleg Babin via Tarantool-patches 2021-07-05 20:53 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-06 8:55 ` Oleg Babin via Tarantool-patches 2021-07-02 21:36 ` [Tarantool-patches] [PATCH vshard 7/6] util: truncate too long fiber name Vladislav Shpilevoy via Tarantool-patches 2021-07-05 9:23 ` Oleg Babin via Tarantool-patches 2021-08-03 21:55 ` [Tarantool-patches] [PATCH vshard 0/6] Master discovery Vladislav Shpilevoy via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=888cee3d83fff78411e0cf96ee6b2e8292887677.1625177221.git.v.shpilevoy@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=olegrok@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --cc=yaroslav.dynnikov@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH vshard 4/6] config: introduce master '\''auto'\'' replicaset option' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox