Skip to content

Commit

Permalink
Merge pull request #17476 from bzwei/playbook_runner_ttl
Browse files Browse the repository at this point in the history
Honor user provided execution_ttl option
  • Loading branch information
mkanoor authored May 29, 2018
2 parents bfcd5a4 + bfb3c7a commit 75cbaf4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::PlaybookRunner < ::Job
DEFAULT_EXECUTION_TTL = 10 # minutes

# options are job table columns, including options column which is the playbook context info
def self.create_job(options)
super(name, options.with_indifferent_access)
Expand All @@ -9,6 +11,11 @@ def minimize_indirect
@minimize_indirect
end

def current_job_timeout(_timeout_adjustment = 1)
@execution_ttl ||=
(options[:execution_ttl].try(:to_i) || DEFAULT_EXECUTION_TTL) * 60
end

def start
time = Time.zone.now
update_attributes(:started_on => time)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@
end
end

describe '#current_job_timeout' do
context 'timeout set in options' do
let(:options) { {:execution_ttl => 50} }

it 'uses customized timeout value' do
expect(subject.current_job_timeout).to eq(3000)
end
end

context 'timeout not set in options' do
let(:options) { {} }

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
context 'hosts are given' do
# Use string key to also test the indifferent accessibility
Expand Down

0 comments on commit 75cbaf4

Please sign in to comment.