Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sporadic ansible-runner macOS bug and remove extra listener thread #23229

Merged
merged 1 commit into from
Oct 12, 2024

Commits on Oct 11, 2024

  1. Fix sporadic ansible-runner macOS bug and remove extra listener thread

    It was found that on macOS a sporadic failure would occur where the internal listener,
    while started, wouldn't actually start listening right away, causing the listener to
    miss the file we were waiting for.
    
    The listen gem [creates an internal thread, `@run_thread`][1], which on most target systems
    is where the actually listening is done. However, [on macOS, `@run_thread` creates a
    second thread, `@worker_thread`][2], which does the actual listening. It's possible that
    although the listener is started, the `@worker_thread` hasn't actually started yet.
    This leaves a window where the target_path we are waiting on can actually be created
    before the `@worker_thread` is started and we "miss" the creation of the target_path.
    This commit ensures that we won't move on until that thread is ready, further ensuring
    we can't miss the creation of the target_path.
    
    Ansible::Runner#wait_for was also creating an extra thread when starting the listener,
    but this thread is unnecessary as the listen gem creates its own internal thread under
    the covers.
    
    [1]: https://github.com/guard/listen/blob/f186b2fa159a2458f3ff7e8680c3a4fcbdc636d1/lib/listen/adapter/base.rb#L75
    [2]: https://github.com/guard/listen/blob/f186b2fa159a2458f3ff7e8680c3a4fcbdc636d1/lib/listen/adapter/darwin.rb#L49
    Fryguy committed Oct 11, 2024
    Configuration menu
    Copy the full SHA
    5ae61a1 View commit details
    Browse the repository at this point in the history