From ab5c4f8654be783904579e0cc63b7d61d467c35f Mon Sep 17 00:00:00 2001 From: Igor Zolotarev Date: Thu, 20 Jun 2024 01:47:18 +0300 Subject: [PATCH] Add cartridge.get_opts --- CHANGELOG.rst | 14 ++++++++++++++ cartridge.lua | 29 +++++++++++++++++++++++++---- cartridge/logging_whitelist.lua | 7 ++++++- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 11f7b56fa..7b38bfa8a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 ------------------------------------------------------------------------------- diff --git a/cartridge.lua b/cartridge.lua index 23efa16ea..2d25b24a7 100644 --- a/cartridge.lua +++ b/cartridge.lua @@ -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. @@ -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. @@ -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 @@ -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) @@ -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, @@ -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 @@ -1272,3 +1289,7 @@ return { -- @function admin_expel_server admin_expel_server = lua_api_deprecated.expel_server, } + +rawset(_G, 'cartridge', M) + +return M diff --git a/cartridge/logging_whitelist.lua b/cartridge/logging_whitelist.lua index ec21d27a9..50b55543f 100644 --- a/cartridge/logging_whitelist.lua +++ b/cartridge/logging_whitelist.lua @@ -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', @@ -20,6 +24,7 @@ local cartridge_opts = { 'webui_enforce_root_redirect', 'webui_prefix', 'workdir', + } local box_opts = {