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 009FA27270 for ; Tue, 31 Jul 2018 07:29:03 -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 40vVn4zCVpJ0 for ; Tue, 31 Jul 2018 07:29:02 -0400 (EDT) Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (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 AB305267B0 for ; Tue, 31 Jul 2018 07:29:02 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 4/4] Introduce storage reload evolution References: <1e067dd68d69270ccf5aea2ab73548ebd9a0f2ad.1532940401.git.avkhatskevich@tarantool.org> <3d8a81f7-33a6-bf1d-809f-ae5b95730a64@tarantool.org> From: Alex Khatskevich Message-ID: <7cd20cfe-982e-fb39-3950-100f51fce1ec@tarantool.org> Date: Tue, 31 Jul 2018 14:29:00 +0300 MIME-Version: 1.0 In-Reply-To: <3d8a81f7-33a6-bf1d-809f-ae5b95730a64@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-US 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: Vladislav Shpilevoy , tarantool-patches@freelists.org On 30.07.2018 14:55, Vladislav Shpilevoy wrote: > Thanks for the patch! See 3 comments below. > >> diff --git a/test/lua_libs/git_util.lua b/test/lua_libs/git_util.lua >> new file mode 100644 >> index 0000000..a75bb08 >> --- /dev/null >> +++ b/test/lua_libs/git_util.lua >> @@ -0,0 +1,51 @@ >> +-- >> +-- Lua bridge for some of the git commands. >> +-- >> +local os = require('os') >> + >> +local temp_file = 'some_strange_rare_unique_file_name_for_git_util' > > 1. C library has a ready solution: tmpfile() and tmpnam() functions > that have Lua API: io.tmpfile() to open a tmp file and automatically > delete it on close, and os.tmpname that generates really unique tmp > file name. Please, use. io.tmpfile() is used. > >> + >> +-- >> +-- Exec a git command. >> +-- @param params Table of parameters: >> +--        * options - git options. >> +--        * cmd - git command. >> +--        * args - command arguments. >> +--        * dir - working directory. >> +--        * fout - write output to the file. >> +local function exec_cmd(params) >> +    local fout = params.fout >> +    local shell_cmd = {'git'} >> +    for _, param in pairs({'options', 'cmd', 'args'}) do >> +        table.insert(shell_cmd, params[param]) >> +    end >> +    if fout then >> +        table.insert(shell_cmd, ' >' .. fout) >> +    end >> +    shell_cmd = table.concat(shell_cmd, ' ') >> +    if params.dir then >> +        shell_cmd = string.format('cd %s && %s', params.dir, shell_cmd) >> +    end >> +    local res = os.execute(shell_cmd) >> +    assert(res == 0, 'Git cmd error: ' .. res) >> +end >> + >> +local function log_hashes(params) >> +    params.args = "--format='%h' " .. params.args >> +    local local_temp_file = string.format('%s/%s', os.getenv('PWD'), >> temp_file) >> +    params.fout = local_temp_file >> +    params.cmd = 'log' >> +    exec_cmd(params) >> +    local lines = {} >> +    for line in io.lines(local_temp_file) do >> +        table.insert(lines, line) >> +    end >> +    os.remove(local_temp_file) >> +    return lines >> +end >> + >> + > > 2. Too many empty lines. deleted > >> +return { >> +    exec_cmd = exec_cmd, >> +    log_hashes = log_hashes >> +} > > 3. What about router evolution? Reload evolution is created to make able to reload from one version to another in in case of noticeable internal changes. As restarting router is much cheaper than restarting a storage and reload evolution adds extra complexity, let us make users to restart the server in case of the noticeable changes.