From: Jan Provaznik <jprovazn(a)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/models/deployment.rb | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
index 9251b36..de2dc63 100644
--- a/src/app/models/deployment.rb
+++ b/src/app/models/deployment.rb
@@ -124,6 +124,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
@@ -142,9 +143,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 ")
--
1.7.4