Skip to content

Commit

Permalink
Add cartridge.get_opts
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvar-antonsson committed Jun 19, 2024
1 parent 9634d88 commit ab5c4f8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ and this project adheres to
Unreleased
-------------------------------------------------------------------------------

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

- ``cartirdge.get_opts()`` function to get current Cartridge options.

- More logging cartridge options on start.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Changed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- ``cartridge`` is a global variable now.

-------------------------------------------------------------------------------
[2.12.1] - 2024-06-06
-------------------------------------------------------------------------------
Expand Down
29 changes: 25 additions & 4 deletions cartridge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ if not ok then
VERSION = 'unknown'
end

local cartridge_opts

--- Vshard storage group configuration.
--
-- Every vshard storage must be assigned to a group.
Expand Down Expand Up @@ -276,7 +278,6 @@ end
-- env `TARANTOOL_UPLOAD_PREFIX`,
-- args `--upload-prefix`)
--

-- @tparam ?boolean opts.enable_failover_suppressing
-- Enable failover suppressing. It forces eventual failover
-- to stop in case of constant switching.
Expand Down Expand Up @@ -304,9 +305,14 @@ end
-- env `TARANTOOL_SET_COOKIE_HASH_MEMBERSHIP`,
-- args `--set-cookie-hash-membership`)
--
-- @tparam ?boolean opts.rebalancer_mode
-- Rebalancer mode for vshard cluster. See vshard doc for more details.
-- env `TARANTOOL_REBALANCER_MODE`,
-- args `--rebalancer-mode`)
--
-- @tparam ?table box_opts
-- tarantool extra box.cfg options (e.g. memtx_memory),
-- that may require additional tuning
-- tarantool extra box.cfg options (e.g. force_recovery),
-- that may require additional tuning on startup.
--
-- @return[1] true
-- @treturn[2] nil
Expand Down Expand Up @@ -984,6 +990,7 @@ local function cfg(opts, box_opts)
confapplier.log_bootinfo()
end

--[[global]] cartridge_opts = opts
if rawget(_G, '__TEST') ~= true then
local crg_opts_to_logs = table.deepcopy(opts)

Expand All @@ -1007,7 +1014,7 @@ end
_G.cartridge_get_schema = twophase.get_schema
_G.cartridge_set_schema = twophase.set_schema

return {
local M = {
VERSION = VERSION,
_VERSION = VERSION,

Expand All @@ -1023,6 +1030,16 @@ return {
-- @function is_healthy
is_healthy = topology.cluster_is_healthy,

--- Get cartridge opts.
-- It's like calling **box.cfg** without arguments, but returns cartridge opts.
--
-- @function get_opts
-- @treturn[1] table Catridge opts
-- @treturn[2] nil If cartridge opts are not set
get_opts = function()
return table.deepcopy(cartridge_opts)
end,

--- Global functions.
-- @section globals

Expand Down Expand Up @@ -1272,3 +1289,7 @@ return {
-- @function admin_expel_server
admin_expel_server = lua_api_deprecated.expel_server,
}

rawset(_G, 'cartridge', M)

return M
7 changes: 6 additions & 1 deletion cartridge/logging_whitelist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ local cartridge_opts = {
'auth_backend_name',
'auth_enabled',
'bucket_count',
'rebalancer_mode',
'console_sock',
'disable_raft_on_small_clusters',
'enable_failover_suppressing',
'enable_synchro_mode',
'http_enabled',
'http_host',
'http_port',
'rebalancer_mode',
'roles',
'roles_reload_allowed',
'set_cookie_hash_membership',
'swim_broadcast',
'upgrade_schema',
'upload_prefix',
Expand All @@ -20,6 +24,7 @@ local cartridge_opts = {
'webui_enforce_root_redirect',
'webui_prefix',
'workdir',

}

local box_opts = {
Expand Down

0 comments on commit ab5c4f8

Please sign in to comment.