[tarantool-patches] Re: [PATCH] tarantoolctl: return an error on enter to a dead socket.

  • From: Sergey Petrenko <sergepetrenko@xxxxxxxxxxxxx>
  • To: Konstantin Osipov <kostja@xxxxxxxxxxxxx>, tarantool-patches@xxxxxxxxxxxxx
  • Date: Wed, 18 Jul 2018 12:19:42 +0300

Hi!

18.07.2018 8:19, Konstantin Osipov пишет:

* Serge Petrenko <sergepetrenko@xxxxxxxxxxxxx> [18/07/16 15:14]:

Tarantoolctl enter didn't check whether connection to a socket was established
if a socket file existed. It just executed a local console.
Fix this by adding a check and an error, also add a test case.

Closes #3364
  extra/dist/tarantoolctl.in         | 19 ++++++++++++-------
  test/app-tap/tarantoolctl.test.lua | 29 ++++++++++++++++++++++++++++-
  2 files changed, 40 insertions(+), 8 deletions(-)

+    local status, err = pcall(function()
+        test:test("check error codes in case of enter", function(test_i)
+            test_i:plan(6)
+            check_ok(test_i, dir, 'enter', 'script', 1, nil, "Can't connect 
to")
+            check_ok(test_i, dir, 'start', 'script', 0)
+            os.execute(("kill $(cat %s/script.pid)"):format(dir))
I don't understand how this works. Simply sending
SIGTERM to tarantool would should it down gracefully and remove
the socket. If it doesn't, it's a bug. You should use SIGKILL if
Doing
  tarantoolctl start testctl
  kill (tarantool instance pid)
Leaves the socket intact on my pc.
tarantoolctl stop also first explicitly deletes the socket
file and then sends SIGTERM to the instance.
Don't know if it's ok.

you wanted to create a dead socket. But then again why do you need
to start an instance in order to get a dead socket? Can't you make
it simpler and create a dead socket with fio API?
Do you mean create a file with fio.open(sock, 'O_CREAT')?
It won't be a 'real' socket, but I tried it, and the tests seem to
work.
Because AFAIU there is no way to create a unix socket without
starting to listen on it.
That's what I'm doing now:
        test_i:plan(4)
        check_ok(test_i, dir, 'enter', 'script', 1, nil, "Can't connect to")
        local console_sock = 'script.control'
        console_sock = fio.pathjoin(fio.dirname(dir), console_sock)
        fio.open(console_sock, 'O_CREAT')
        check_ok(test_i, dir, 'enter', 'script', 1, nil, "Can't connect to")
        fio.unlink(console_sock)


Other related posts: