From 40abd08a42b1d4aacf4ba027df9d2ec997708e4b Mon Sep 17 00:00:00 2001 From: Madhu Kanoor Date: Mon, 16 Jul 2018 16:42:59 -0400 Subject: [PATCH] Allow for empty strings in the execution_ttl field https://bugzilla.redhat.com/show_bug.cgi?id=1601538 An empty string yields a 0 timeout value causing jobs to be terminated right away. --- .../automation_manager/playbook_runner.rb | 2 +- .../automation_manager/playbook_runner_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/manageiq/providers/embedded_ansible/automation_manager/playbook_runner.rb b/app/models/manageiq/providers/embedded_ansible/automation_manager/playbook_runner.rb index 2f2df6b1002..3c72d719f8b 100644 --- a/app/models/manageiq/providers/embedded_ansible/automation_manager/playbook_runner.rb +++ b/app/models/manageiq/providers/embedded_ansible/automation_manager/playbook_runner.rb @@ -13,7 +13,7 @@ def minimize_indirect def current_job_timeout(_timeout_adjustment = 1) @execution_ttl ||= - (options[:execution_ttl].try(:to_i) || DEFAULT_EXECUTION_TTL) * 60 + (options[:execution_ttl].present? ? options[:execution_ttl].try(:to_i) : DEFAULT_EXECUTION_TTL) * 60 end def start diff --git a/spec/models/manageiq/providers/embedded_ansible/automation_manager/playbook_runner_spec.rb b/spec/models/manageiq/providers/embedded_ansible/automation_manager/playbook_runner_spec.rb index c38780d0249..e4434146f09 100644 --- a/spec/models/manageiq/providers/embedded_ansible/automation_manager/playbook_runner_spec.rb +++ b/spec/models/manageiq/providers/embedded_ansible/automation_manager/playbook_runner_spec.rb @@ -48,6 +48,14 @@ expect(subject.current_job_timeout).to eq(described_class::DEFAULT_EXECUTION_TTL * 60) end end + + context 'timeout is blank in options' do + let(:options) { {:execution_ttl => ""} } + + it 'uses default timeout value' do + expect(subject.current_job_timeout).to eq(described_class::DEFAULT_EXECUTION_TTL * 60) + end + end end describe '#create_inventory' do