[PATCH conductor] Quick Fix, destroy method is not called for ec2 and Mock instances, or if instance is in CREATE_FAILED state

Tomas Hrcka thrcka at redhat.com
Tue Dec 13 09:37:24 UTC 2011


---
 src/app/models/instance.rb |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index 279e1a7..d146cce 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -483,14 +483,16 @@ class Instance < ActiveRecord::Base
   ]
 
   def destroy_on_provider
-    begin
-      @task = self.queue_action(self.owner, 'destroy')
-      unless @task
-        raise ActionError.new("destroy cannot be performed on this instance.")
+    if (provider_account.label != "ec2" or provider_account.label != "mock") and state != STATE_CREATE_FAILED
+      begin
+        @task = self.queue_action(self.owner, 'destroy')
+        unless @task
+          raise ActionError.new("destroy cannot be performed on this instance.")
+        end
+        Taskomatic.destroy_instance(@task)
+      rescue Exception => e
+        retry if self.tasks.last.action != 'destroy'
       end
-      Taskomatic.destroy_instance(@task)
-    rescue Exception => e
-      retry if self.tasks.last.action != 'destroy'
     end
   end
 
-- 
1.7.7.4




More information about the aeolus-devel mailing list