Skip to content

Commit

Permalink
Need to turn off Ansible runner timeout for automate.
Browse files Browse the repository at this point in the history
Automate has its own timeout. This Ansible runner timeout does not play nice with automate timeout.

https://bugzilla.redhat.com/show_bug.cgi?id=1750370
  • Loading branch information
lfu committed Sep 10, 2019
1 parent 7a820ad commit 64f841d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions app/models/manageiq/providers/ansible_playbook_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def launch_runner
Ansible::Runner.run_async(env_vars, extra_vars, playbook_path, kwargs)
end

def process_abort(*args)
response = Ansible::Runner::ResponseAsync.load(context[:ansible_runner_response])
response.stop
super
end

private

def verify_options
Expand Down
2 changes: 1 addition & 1 deletion app/models/manageiq/providers/ansible_runner_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def execute
def poll_runner
response = Ansible::Runner::ResponseAsync.load(context[:ansible_runner_response])
if response.running?
if started_on + options[:timeout] < Time.now.utc
if options[:timeout].present? && (started_on + options[:timeout]) < Time.now.utc
response.stop

queue_signal(:abort, "ansible #{execution_type} has been running longer than timeout", "error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def run(vars = {})
credentials = collect_credentials(vars)

kwargs = {:become_enabled => vars[:become_enabled]}
kwargs[:timeout] = vars[:execution_ttl].to_i.minutes if vars[:execution_ttl].present?
kwargs[:verbosity] = vars[:verbosity].to_i if vars[:verbosity].present?
kwargs[:timeout] = vars[:execution_ttl].present? ? vars[:execution_ttl].to_i.minutes : nil
kwargs[:verbosity] = vars[:verbosity].to_i if vars[:verbosity].present?

workflow.create_job({}, extra_vars, playbook_vars, vars[:hosts], credentials, kwargs).tap do |job|
job.signal(:start)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
expect(job.options[:extra_vars]).to eq(:instance_ids => ["i-3434"])
expect(job.options[:configuration_script_source_id]).to eq(ansible_script_source.id)
expect(job.options[:playbook_relative_path]).to eq(playbook.name)
expect(job.options[:timeout]).to eq(1.hour)
expect(job.options[:timeout]).to be nil
expect(job.options[:verbosity]).to eq(0)
end

Expand Down

0 comments on commit 64f841d

Please sign in to comment.