Repository navigation
correctly handle slow fork-exec in local connect - #208
Conversation
Some tools, such as https://www.airlockdigital.com interfere with fork/exec pattern in that there is an increased delay between `cmd.Start` and when that command actually starts running. In our fork/exec chain for `signadot local`, after `cmd.Start()` we check if the sub-process is ready in the sense of writing its pid file. This PR 1. increases the timeout for this from 1 to 30sec; and 2. does not return an error if there is a timeout waiting for the sub-process to be ready because that causes `signadot local connect` to report an error but not cleanup, but the background process is still there. Rather it sends a warning to the log. 3. improves error reporting (depends in part on signadot/libconnect#125)
joehorsnell
left a comment
There was a problem hiding this comment.
Looks good @scott-cotton - thanks.
A couple of comments 👍
| } | ||
| // and check to see that it succeeded | ||
| return processes.WaitReady(pidFile, time.Second, cmd.Process, log) | ||
| if err := processes.WaitReady(pidFile, 30*time.Second, cmd.Process, log); err != nil { |
There was a problem hiding this comment.
This seems to be the key line - nice 👌
My only thought here is that going from one second to 30 is perhaps a bit too much? In the error case (eg if AirLock blocks process execution completely), will this then hang for 30s before terminating?
You could maybe increase it to 5 or 10 seconds by default, and potentially provide a --timeout command-line switch to the connect sub-command to increase it, if necessary?
There was a problem hiding this comment.
Ideally I think one should plum the --wait-timeout flag from signadot local connect here but priorities prevent me from doing that just now.
Yes, if AirLock or something blocks it completely or beyond --wait-timeout, it will hang the call to signadot local connect.
I'll see if I can add the --wait-timeout plumbing.
There was a problem hiding this comment.
Got it. Maybe you could add the --wait-timeout switch later? But I think that the default timeout can be lower than 30s, maybe 10s?
There was a problem hiding this comment.
I think the timeout there should be the same thing as --wait-timeout as passed to signadot local connect (and the --wait-timeout is already there for signadot local connect, and has a default of 10sec).
There was a problem hiding this comment.
Sounds good 👍.
Thanks again for getting this fix done quickly!
There was a problem hiding this comment.
Thanks again for getting this fix done quickly!
Thanks for your help debugging it!
Some tools, such as https://www.airlockdigital.com interfere with fork/exec pattern in that there is an increased delay between
cmd.Startand when that command actually starts running.In our fork/exec chain for
signadot local, aftercmd.Start()we check if the sub-process is ready in the sense of writing its pid file.This PR
--wait-timeoutas passed tolocal connect(which defaults to 10sec)signadot local connectto report an error but not cleanup, but the background process is still there. Rather it sends a warning to the log.