Skip to content

Commit

Permalink
Rely on 10 minute starting_timeout instead of a heartbeating thread
Browse files Browse the repository at this point in the history
The server process allows "starting" workers up to 10 minutes to start
before marking them as not responding.  We can use this starting_timeout
instead of heartbeating in a thread while another thread runs the
ansible setup playbook (configure).
  • Loading branch information
jrafanie committed Feb 23, 2017
1 parent 489bf7c commit 14ee97b
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions app/models/embedded_ansible_worker/runner.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
class EmbeddedAnsibleWorker::Runner < MiqWorker::Runner
def prepare
Thread.new do
setup_ansible
started_worker_record
end
self.wait_for_worker_monitor = false

def prepare
# Override prepare so we don't get set as started
self
end

# This thread runs forever until a stop request is received, which with send us to do_exit to exit our thread
def do_work_loop
Thread.new do
_log.info("waiting for ansible to start...")
loop do
# handle if the ansible setup blew up or timed out
break if worker.reload.started?
heartbeat
send(poll_method)
end
begin
setup_ansible
started_worker_record

update_embedded_ansible_provider
update_embedded_ansible_provider

_log.info("entering ansible monitor loop")
loop do
do_work
send(poll_method)
_log.info("entering ansible monitor loop")
loop do
do_work
send(poll_method)
end
rescue => err
_log.log_backtrace(err)
do_exit
end
end
end
Expand Down

0 comments on commit 14ee97b

Please sign in to comment.