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

Track and kill embedded ansible monitoring thread #15612

Conversation

jrafanie
Copy link
Member

@jrafanie jrafanie commented Jul 19, 2017

This PR will prevent embedded ansible monitoring threads from piling up if the setup takes a very long time, leading to the bug fixed by: ManageIQ/manageiq-gems-pending#247.

Do we need this on euwe?

https://bugzilla.redhat.com/show_bug.cgi?id=1469307
https://bugzilla.redhat.com/show_bug.cgi?id=1468898

Tag the monitor thread with the worker info so we can kill it later

When the server starts the monitor thread, store the worker class and id
in the thread object so the server can then kill that thread if required
later.

Implement stop/kill/terminate in the same way:  look for the thread
containing the worker's class and id in Thread.list, exit it, and
destroy the worker row.
Delegate the pid knowledge to the worker row.

Each worker can implement their own way to invoke processes so let them
choose and persist their pid value, don't assume we can use Process.pid.

@@ -177,7 +177,6 @@ def find_worker_record

def starting_worker_record
find_worker_record
@worker.pid = Process.pid
Copy link
Member Author

@jrafanie jrafanie Jul 19, 2017

Choose a reason for hiding this comment

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

This is important, as the worker model will store the self.pid= with the result of MiqWorker#start_runner,
which when changed to return the Thread identifier(an object_id), gets overwritten by this line 180.

We still need to let the worker set the pid when we call start_runner and in the case of the EmbeddedAnsible worker, nil.

We need to remove most places making assumptions about calling Process.pid for the workers.

@jrafanie jrafanie closed this Jul 19, 2017
@jrafanie jrafanie reopened this Jul 19, 2017
@jrafanie jrafanie force-pushed the track_and_kill_embedded_ansible_monitoring_thread branch from 37a5bc6 to d9f7c39 Compare July 20, 2017 19:59
jrafanie added 2 commits July 21, 2017 11:00
Each worker can implement their own way to invoke processes so let them
choose and persist their pid value, don't assume we can use Process.pid.

https://bugzilla.redhat.com/show_bug.cgi?id=1469307
https://bugzilla.redhat.com/show_bug.cgi?id=1468898
When the server starts the monitor thread, store the worker class and id
in the thread object so the server can then kill that thread if required
later.

Implement stop/kill/terminate in the same way:  look for the thread
containing the worker's class and id in Thread.list, exit it, and
destroy the worker row.

https://bugzilla.redhat.com/show_bug.cgi?id=1469307
https://bugzilla.redhat.com/show_bug.cgi?id=1468898
@jrafanie jrafanie force-pushed the track_and_kill_embedded_ansible_monitoring_thread branch from d9f7c39 to d493381 Compare July 21, 2017 15:00
@jrafanie jrafanie changed the title [WIP] Track and kill embedded ansible monitoring thread Track and kill embedded ansible monitoring thread Jul 21, 2017
@jrafanie jrafanie removed the wip label Jul 21, 2017
nil # return no pid

t[:worker_class] = self.class.name
t[:worker_id] = id
Copy link
Member Author

Choose a reason for hiding this comment

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

Here we're setting thread instance variables in the Thread object so we can locate the thread for this worker later.

@jrafanie
Copy link
Member Author

ok @Fryguy @gtanzillo @carbonin ready for review

@miq-bot
Copy link
Member

miq-bot commented Jul 21, 2017

Checked commits jrafanie/manageiq@63816f4~...d493381 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks fine. 🍪

@Fryguy Fryguy merged commit d6c4949 into ManageIQ:master Jul 21, 2017
@Fryguy Fryguy added this to the Sprint 65 Ending Jul 24, 2017 milestone Jul 21, 2017
@jrafanie jrafanie deleted the track_and_kill_embedded_ansible_monitoring_thread branch July 21, 2017 16:23
Copy link
Member

@carbonin carbonin left a comment

Choose a reason for hiding this comment

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

Guess I'm a bit late here, but maybe worth posting anyway.

end

alias terminate kill
alias stop kill
Copy link
Member

Choose a reason for hiding this comment

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

Do we want this? I think this worker still should be able to exit cleanly with stop if it is heartbeating, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think you're right but I need to do some testing.

end
end

alias terminate kill
Copy link
Member

Choose a reason for hiding this comment

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

Right now the only other workers that implement #terminate are the UI workers. Do we need that here also?

@simaishi
Copy link
Contributor

Backported to Fine via #15631

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants