-
Notifications
You must be signed in to change notification settings - Fork 897
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
Use inotify to wait for ansible-runner pid file creation #20666
Use inotify to wait for ansible-runner pid file creation #20666
Conversation
57743dd
to
dc72b0f
Compare
4ec7161
to
89af2a2
Compare
89af2a2
to
90fdb09
Compare
90fdb09
to
60d2f2a
Compare
I'd like to verify this works on a Mac (or at least what the behavior of inotify is) |
On a Mac:
|
The listen gem bridges rb-inotify (linux) and rb-fsevent (mac) (and technically windows and others as well)...we may want to just use the listen gem. |
This doesn't look good: https://travis-ci.com/github/ManageIQ/manageiq/jobs/396503769#L720-L723 Both previous builds failed with this error. |
9270cdd
to
456eb20
Compare
@agrare Do we do any other ansible runner stuff in other repos? If so, can we cross-repo-test those? |
Checked commits agrare/manageiq@60d2f2a~...3aa562a with ruby 2.6.3, rubocop 0.69.0, haml-lint 0.28.0, and yamllint |
Works on Linux and Mac OSX and is passing specs, taking out of WIP and running cross-repo tests |
Yeah we have specs with do |
Okay cross-repo tests are green |
We my want to prefer #20667 for backport purposes, but i'm ok with introducing a new gem on backport. @agrare @NickLaMuro Thoughts? |
My 2cents would be for using #20667 for the backport since there is no gem, and I think all of our tests were done without testing this in containers. I was able to test #20667 directly on the While I do agree this is probably the #Right™ solution long term, I think there is a lot added to the product to justify it being a backport. |
Yeah I think #20667 is probably safer for backport, maybe updated to check the |
@NickLaMuro You'll probably have to make it a direct-to-jansa PR |
Commented on this part specifically as to why I don't want to do this: #20667 (comment) Adds another race condition possibility, and the worst case with this is we wait the full 10 seconds if the
yup, I will reopen as a new PR. |
Backported to jansa via #20670 |
When using
ansible-runner start
a daemon is forked off and runs the playbook in the background allowing the caller to continue one. It then provides a method to check if the playbook is still running via theansible-runner is-alive
call.This call checks for the existence of the
private_data_dir/pid
file and sends akill(2)
syscall to check that the process is alive. Once the daemon exits thepid
file is deleted andansible-runner is-alive
returns1
If
ansible-runner is-alive
is called before the daemon is forked then thepid
file hasn't been created yet andis-alive
returns that the process isn't running which, while technically true, doesn't help a caller who wants to wait until the daemon has started and exited.Since
ansible-runner is-alive
checks for thepid
file it isn't safe to issue theis-alive
check until after this file has been created if the purpose of callingis-alive
is to check if the daemon has exited.This can be done very efficiently by using
inotify
/fs_notify
to catch filesystem events using watches. We setup a filesystem watch on the/tmp/ansible-runner
tempdir looking for thepid
file and as soon as it is created break out and return to the caller.This makes all subsequent
ansible-runner is-alive
calls safe since it is impossible for the call to be issued before the daemon has started running.Cross Repo Tests: ManageIQ/manageiq-cross_repo-tests#187