[PATCH 2/4] BZ 796528 - instance's config params are now handled from taskomatic
jprovazn at redhat.com
jprovazn at redhat.com
Fri Mar 9 07:39:01 UTC 2012
From: Jan Provaznik <jprovazn at redhat.com>
Reason for moving this is that taskomatic's create_instance method automatically
sets create_failed instance's method when an exception occurs and then reraises
this exception which is handled in deployment's launch method. add_instance_config!
method raises an exceptions too and in that case we want to set create_failed state
too.
---
src/app/models/deployment.rb | 10 +++-------
src/app/models/instance.rb | 8 ++------
src/app/util/taskomatic.rb | 3 ++-
3 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
index b8e4a31..23a664f 100644
--- a/src/app/models/deployment.rb
+++ b/src/app/models/deployment.rb
@@ -198,7 +198,6 @@ class Deployment < ActiveRecord::Base
# then, find a single provider account where all instances can launch
# then, if a config server is being used
# then generate the instance configs for each instance,
- # then send the instance configs to the config server,
# finally, launch the instances
#
# TODO: need to be able to handle deployable-level errors
@@ -226,15 +225,12 @@ class Deployment < ActiveRecord::Base
instances.each do |instance|
match = all_inst_match.find{|m| m.instance.id == instance.id}
begin
- if instance.launch(match, user, config_server, instance_configs[instance.uuid])
- status[:successes][instance.name] = 'launched'
- else
- status[:errors][instance.name] = 'failed'
- end
+ instance.launch!(match, user, config_server, instance_configs[instance.uuid])
+ status[:successes][instance.name] = 'launched'
rescue
+ status[:errors][instance.name] = $!.message.to_s.split("\n").first
logger.error $!.message
logger.error $!.backtrace.join("\n ")
- status[:errors][instance.name] = $!.message.to_s.split("\n").first
end
end
status
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index e67532f..967b26c 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -414,16 +414,12 @@ class Instance < ActiveRecord::Base
[matched, errors]
end
- def launch(match, user, config_server, config)
- if config_server
- add_instance_config!(config_server, config)
- end
+ def launch!(match, user, config_server, config)
# create a taskomatic task
task = InstanceTask.create!({:user => user,
:task_target => self,
:action => InstanceTask::ACTION_CREATE})
- Taskomatic.create_instance(task, match)
- task.state != Task::STATE_FAILED
+ Taskomatic.create_instance!(task, match, config_server, config)
end
diff --git a/src/app/util/taskomatic.rb b/src/app/util/taskomatic.rb
index 5ddb782..a7181dc 100644
--- a/src/app/util/taskomatic.rb
+++ b/src/app/util/taskomatic.rb
@@ -16,11 +16,12 @@
module Taskomatic
- def self.create_instance(task, match)
+ def self.create_instance!(task, match, config_server, config)
begin
task.state = Task::STATE_PENDING
task.save!
+ task.instance.add_instance_config!(config_server, config) if config_server
task.instance.provider_account = match.provider_account
task.instance.create_auth_key unless task.instance.instance_key
--
1.7.7.6
More information about the aeolus-devel
mailing list