From: Jan Provaznik jprovazn@redhat.com
- condormatic_instance_create method moved out of the instance create transaction - if an instance's start task has status failed, it's interpreted as an instances start failure in the UI. This could be simplified by throwing exceptions in condormatic_instance_create but I don't want to do bigger changes at this point. --- src/app/controllers/instances_controller.rb | 2 +- src/app/models/deployment.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/app/controllers/instances_controller.rb b/src/app/controllers/instances_controller.rb index 88fda19..6e62f1b 100644 --- a/src/app/controllers/instances_controller.rb +++ b/src/app/controllers/instances_controller.rb @@ -73,8 +73,8 @@ class InstancesController < ApplicationController @task = InstanceTask.create!({:user => current_user, :task_target => @instance, :action => InstanceTask::ACTION_CREATE}) - condormatic_instance_create(@task) end + condormatic_instance_create(@task) rescue init_new_instance_attrs flash[:warning] = "Failed to launch instance: #{$!}" diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb index 65423e9..569e054 100644 --- a/src/app/models/deployment.rb +++ b/src/app/models/deployment.rb @@ -126,6 +126,7 @@ class Deployment < ActiveRecord::Base deployable_xml.assemblies.each do |assembly| # TODO: for now we try to start all instances even if some of them fails begin + task = nil Instance.transaction do hw_profile = HardwareProfile.frontend.find_by_name(assembly.hwp) raise "Hardware Profile #{assembly.hwp} not found." unless hw_profile @@ -144,9 +145,13 @@ class Deployment < ActiveRecord::Base task = InstanceTask.create!({:user => user, :task_target => instance, :action => InstanceTask::ACTION_CREATE}) - condormatic_instance_create(task) end - status[:successes][assembly.name] = 'launched' + condormatic_instance_create(task) + if task.state == Task::STATE_FAILED + status[:errors][assembly.name] = 'failed' + else + status[:successes][assembly.name] = 'launched' + end rescue logger.error $! logger.error $!.backtrace.join("\n ")
aeolus-devel@lists.fedorahosted.org