Skip to content

Commit

Permalink
Merge pull request #19555 from lfu/orch_prov_failed_1773595
Browse files Browse the repository at this point in the history
Improve the error handling of OrchestrationTemplateRunner

(cherry picked from commit 6a79d77)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1783389
  • Loading branch information
gmcculloug authored and simaishi committed Dec 13, 2019
1 parent a335940 commit 117a9e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Expand Up @@ -42,8 +42,8 @@ def deploy_orchestration_stack
save!
my_signal(false, :poll_stack_status, 10)
rescue StandardError => err
_log.log_backtrace(err)
my_signal(minimize_indirect, :post_stack_run, err.message, 'error')
_log.error("Error deploying orchestration stack : #{err.class} - #{err.message}")
my_signal(minimize_indirect, :abort_job, err.message, 'error')
end

def update_orchestration_stack
Expand All @@ -55,8 +55,8 @@ def update_orchestration_stack
save!
my_signal(false, :poll_stack_status, 10)
rescue StandardError => err
_log.log_backtrace(err)
my_signal(minimize_indirect, :post_stack_run, err.message, 'error')
_log.error("Error updating orchestration stack : #{err.class} - #{err.message}")
my_signal(minimize_indirect, :abort_job, err.message, 'error')
end

def poll_stack_status(interval)
Expand All @@ -72,7 +72,7 @@ def poll_stack_status(interval)
my_signal(minimize_indirect, :post_stack_run, "Orchestration stack [#{orchestration_stack.name}] #{status}", 'ok')
when 'rollback_complete', 'delete_complete', /failed$/, /canceled$/
_log.error("Orchestration stack deployment error: #{message}. Please examine stack resources for more details")
my_signal(minimize_indirect, :post_stack_run, "Orchestration stack deployment error: #{message}", 'error')
my_signal(minimize_indirect, :abort_job, "Orchestration stack deployment error: #{message}", 'error')
else
interval = 60 if interval > 60
my_signal(false, :poll_stack_status, interval * 2, :deliver_on => Time.now.utc + interval)
Expand All @@ -81,8 +81,8 @@ def poll_stack_status(interval)
# naming convention requires status to end with "failed"
options.merge!(:orchestration_stack_status => 'check_status_failed', :orchestration_stack_message => err.message)
save!
_log.log_backtrace(err)
my_signal(minimize_indirect, :post_stack_run, err.message, 'error')
_log.error("Error polling orchestration stack status : #{err.class} - #{err.message}")
my_signal(minimize_indirect, :abort_job, err.message, 'error')
end

def post_stack_run(message, status)
Expand Down
2 changes: 2 additions & 0 deletions app/models/service_orchestration.rb
Expand Up @@ -185,6 +185,8 @@ def orchestration_runner_job

def wait_on_orchestration_stack
while deploy_stack_job.orchestration_stack.blank?
raise _("Orchestration template runner finished with error. Check evm.log for details.") if deploy_stack_job.status == 'error'

_log.info("Waiting for the deployment of orchestration stack [#{stack_name}]...")
sleep 2
# Code running with Rails QueryCache enabled,
Expand Down
7 changes: 7 additions & 0 deletions spec/models/service_orchestration_spec.rb
Expand Up @@ -189,6 +189,13 @@
end.and_return(job)
service_with_dialog_options.deploy_orchestration_stack
end

it 'raises runtime error when job finishes with pre-existing stack' do
job = double(:job, :id => 1, :status => 'error', :orchestration_stack => nil)
allow(job).to receive(:signal).with(:start)
allow(ManageIQ::Providers::CloudManager::OrchestrationTemplateRunner).to receive(:create_job).and_return(job)
expect { service_with_dialog_options.deploy_orchestration_stack }.to raise_error(RuntimeError, /Orchestration template runner finished with error/)
end
end

describe '#update_orchestration_stack' do
Expand Down

0 comments on commit 117a9e0

Please sign in to comment.