Skip to content

correctly handle slow fork-exec in local connect - #208

Merged
scott-cotton merged 5 commits into
mainfrom
locald-slow-exec-start
Sep 12, 2025
Merged

scott-cotton merged 5 commits into
mainfrom
locald-slow-exec-start

Conversation

@scott-cotton

@scott-cotton scott-cotton commented Sep 9, 2025 •

Copy link
Copy Markdown
Member

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. sets the timeout for this to --wait-timeout as passed to local connect (which defaults to 10sec)
  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 https://github.com/signadot/libconnect/pull/125)

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)
@scott-cotton scott-cotton changed the title This PR fixes a bug with slow fork-exec correctly handle slow fork-exec Sep 9, 2025

@joehorsnell joehorsnell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @scott-cotton - thanks.

A couple of comments 👍

Comment thread internal/command/locald/locald.go Outdated
}
// 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 {

@joehorsnell joehorsnell Sep 9, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@joehorsnell joehorsnell Sep 9, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍.

Thanks again for getting this fix done quickly!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done in d80c1a0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for getting this fix done quickly!

Thanks for your help debugging it!

@scott-cotton scott-cotton changed the title correctly handle slow fork-exec correctly handle slow fork-exec in local connect Sep 10, 2025

@davixcky davixcky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@scott-cotton
scott-cotton merged commit 5e36264 into main Sep 12, 2025
@scott-cotton
scott-cotton deleted the locald-slow-exec-start branch September 12, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants