From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B5AE12220D for ; Mon, 30 Jul 2018 04:14:58 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Yy__nLvNhItU for ; Mon, 30 Jul 2018 04:14:58 -0400 (EDT) Received: from smtp15.mail.ru (smtp15.mail.ru [94.100.176.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 0CB5E22603 for ; Mon, 30 Jul 2018 04:14:57 -0400 (EDT) From: Georgy Kirichenko Subject: [tarantool-patches] Re: [PATCH v2] lua: fix for option pid_file overwritten by tarantoolctl Date: Mon, 30 Jul 2018 11:14:48 +0300 Message-ID: <3927046.3zLaITeJhd@localhost> In-Reply-To: <20180723170704.63430-1-k.belyavskiy@tarantool.org> References: <20180723170704.63430-1-k.belyavskiy@tarantool.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2058614.d5XhG7yfuP"; micalg="pgp-sha256"; protocol="application/pgp-signature" Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Konstantin Belyavskiy --nextPart2058614.d5XhG7yfuP Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" It looks more better but there are some comments bellow On Monday, July 23, 2018 8:07:04 PM MSK Konstantin Belyavskiy wrote: > During startup tarantoolctl ignores 'pid_file' option and set it to > default value. > This cause a fault if user tries to execute config with option set. > In case of being started with tarantoolctl shadow this option with > additional wrapper around box.cfg. > > Closes #3214 > --- > ticket: https://github.com/tarantool/tarantool/issues/3214 > branch: > https://github.com/tarantool/tarantool/tree/kbelyavs/gh-3214-tarantoolctl-p > idfile-fix extra/dist/tarantoolctl.in | 11 +++++++++++ > test/box/cfg.result | 30 ++++++++++++++++++++++++++++++ > test/box/cfg.test.lua | 12 ++++++++++++ > 3 files changed, 53 insertions(+) > > diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in > index 507ebe8bf..f60c910d8 100755 > --- a/extra/dist/tarantoolctl.in > +++ b/extra/dist/tarantoolctl.in > @@ -471,6 +471,15 @@ local function wrapper_cfg(cfg) > return data > end > > +cfg_callback = nil It would be better if you use local defined closure instead of a global function with a variable > + > +function wrapper_cfg_reload(old_cfg, cfg) > + if old_cfg.pid_file ~= nil and cfg ~= nil and cfg.pid_file ~= nil then > + cfg.pid_file = old_cfg.pid_file > + end > + cfg_callback(old_cfg, cfg) > +end > + > -- It's not 100% result guaranteed function, but it's ok for most cases > -- Won't help in multiple race-conditions > -- Returns nil if Tarantool already started, PID otherwise > @@ -527,6 +536,8 @@ local function start() > end > os.exit(1) > end > + cfg_callback = getmetatable(box.cfg).__call > + getmetatable(box.cfg).__call = wrapper_cfg_reload something like: local old_call = getmetatable(box.cfg).__call getmetatable(box.cfg).__call = function (old_cfg, cfg) ... old_call(...) end > return 0 > end > > diff --git a/test/box/cfg.result b/test/box/cfg.result > index cda7aa0d3..a2df83310 100644 > --- a/test/box/cfg.result > +++ b/test/box/cfg.result > @@ -365,6 +365,36 @@ test_run:cmd("cleanup server cfg_tester4") > - true > ... > --------------------------------------------------------------------------- > ----- +-- Check fix for pid_file option overwritten by tarantoolctl > +--------------------------------------------------------------------------- > ----- +test_run:cmd('create server cfg_tester5 with script = > "box/lua/cfg_test1.lua"') +--- > +- true > +... > +test_run:cmd("start server cfg_tester5") > +--- > +- true > +... > +test_run:cmd('switch cfg_tester5') > +--- > +- true > +... > +box.cfg{pid_file = "current.pid"} > +--- > +... > +test_run:cmd("switch default") > +--- > +- true > +... > +test_run:cmd("stop server cfg_tester5") > +--- > +- true > +... > +test_run:cmd("cleanup server cfg_tester5") > +--- > +- true > +... > +--------------------------------------------------------------------------- > ----- -- Check that 'vinyl_dir' cfg option is not checked as long as > -- there is no vinyl indexes (issue #2664) > --------------------------------------------------------------------------- > ----- diff --git a/test/box/cfg.test.lua b/test/box/cfg.test.lua > index dbb463025..712a165bb 100644 > --- a/test/box/cfg.test.lua > +++ b/test/box/cfg.test.lua > @@ -69,6 +69,18 @@ test_run:cmd("switch default") > test_run:cmd("stop server cfg_tester4") > test_run:cmd("cleanup server cfg_tester4") > > +--------------------------------------------------------------------------- > ----- +-- Check fix for pid_file option overwritten by tarantoolctl > +--------------------------------------------------------------------------- > ----- + > +test_run:cmd('create server cfg_tester5 with script = > "box/lua/cfg_test1.lua"') +test_run:cmd("start server cfg_tester5") > +test_run:cmd('switch cfg_tester5') > +box.cfg{pid_file = "current.pid"} > +test_run:cmd("switch default") > +test_run:cmd("stop server cfg_tester5") > +test_run:cmd("cleanup server cfg_tester5") > + > --------------------------------------------------------------------------- > ----- -- Check that 'vinyl_dir' cfg option is not checked as long as > -- there is no vinyl indexes (issue #2664) --nextPart2058614.d5XhG7yfuP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEFZT35EtIMRTDS5hJnoTdFFzh6LUFAlteyPgACgkQnoTdFFzh 6LXOCQf/VY373t6nFUyqgUjGtB2gRa31bTPD4PXMitS+4skpJcckRX7fOUBWVi4q J9ObiblOfftoj4jpFb7EwiJk3TBIhl20pGywShaCI8oUu7ItERsOfihzyItHSMwr odRJTfE2ilYRY0ufe4Uov5momT01MdFlOLAqdIHoyjeI3ZTXcCU1Fn9sCR8Yso5i O+oGCA/sR3c5PXR+2DqEAA0iK3HSEEbTpQbfuCkJIdxVioxtFTB4fOeH/1ijBcmd PmHNCVbkpJOkuvyt62466jycPEFMEmQU5lIDmBTtw4k5DgRpe1hXUyFVoXetqtxu w/CFaUYpSeFMQ+J4F8oataQXQdqZVg== =XVn5 -----END PGP SIGNATURE----- --nextPart2058614.d5XhG7yfuP--