From 64f841d6e7a4dbf7a4b3a04f8e5cdb524177caa2 Mon Sep 17 00:00:00 2001 From: Lucy Fu Date: Tue, 10 Sep 2019 10:00:17 -0400 Subject: [PATCH] Need to turn off Ansible runner timeout for automate. 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 --- app/models/manageiq/providers/ansible_playbook_workflow.rb | 6 ++++++ app/models/manageiq/providers/ansible_runner_workflow.rb | 2 +- .../automation_manager/configuration_script.rb | 4 ++-- .../automation_manager/configuration_script_spec.rb | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/manageiq/providers/ansible_playbook_workflow.rb b/app/models/manageiq/providers/ansible_playbook_workflow.rb index ed65458d4b49..7c4907170634 100644 --- a/app/models/manageiq/providers/ansible_playbook_workflow.rb +++ b/app/models/manageiq/providers/ansible_playbook_workflow.rb @@ -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 diff --git a/app/models/manageiq/providers/ansible_runner_workflow.rb b/app/models/manageiq/providers/ansible_runner_workflow.rb index f60747cd7bbb..e122ca96117f 100644 --- a/app/models/manageiq/providers/ansible_runner_workflow.rb +++ b/app/models/manageiq/providers/ansible_runner_workflow.rb @@ -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") diff --git a/app/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script.rb b/app/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script.rb index 12fec353a945..5d860bd99fc1 100644 --- a/app/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script.rb +++ b/app/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script.rb @@ -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) diff --git a/spec/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_spec.rb b/spec/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_spec.rb index 5287b7111b73..6ee343ad0b3d 100644 --- a/spec/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_spec.rb +++ b/spec/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_spec.rb @@ -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