[PATCH 2/2] BZ 798549 added exception handling and humanize_error to catch connection refused errors

Tzu-Mainn Chen tzumainn at redhat.com
Tue Mar 13 03:52:18 UTC 2012


---
 src/app/models/deployable.rb |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/app/models/deployable.rb b/src/app/models/deployable.rb
index 83aaa71..97da388 100644
--- a/src/app/models/deployable.rb
+++ b/src/app/models/deployable.rb
@@ -15,6 +15,7 @@
 #
 
 class Deployable < ActiveRecord::Base
+  require 'util/conductor'
   class << self
     include CommonFilterMethods
   end
@@ -152,8 +153,17 @@ class Deployable < ActiveRecord::Base
     deployable_errors ||= []
     deployable_xml.assemblies.each do |assembly|
       assembly_hash = {}
-      image = Aeolus::Image::Warehouse::Image.find(assembly.image_id)
-      if image.nil?
+
+      begin
+        image = Aeolus::Image::Warehouse::Image.find(assembly.image_id)
+      rescue Exception => e
+        error = humanize_error(e.message)
+      end
+
+      if !error.nil?
+        missing_images << assembly.image_id
+        deployable_errors << error
+      elsif image.nil?
         missing_images << assembly.image_id
         deployable_errors << I18n.t("deployables.flash.error.missing_image",
                                     :assembly => assembly.name,
@@ -191,12 +201,17 @@ class Deployable < ActiveRecord::Base
   end
 
   def build_status(images, account)
-    image_statuses = images.map { |i| account.image_status(i) }
-    return :not_built if image_statuses.any? { |status| status == :not_built }
-    return :building if image_statuses.any? { |status| status == :building }
-    return :pushing if image_statuses.any? { |status| status == :pushing }
-    return :not_pushed if image_statuses.any? { |status| status == :not_pushed }
-    :pushed
+    begin
+      image_statuses = images.map { |i| account.image_status(i) }
+      return :not_built if image_statuses.any? { |status| status == :not_built }
+      return :building if image_statuses.any? { |status| status == :building }
+      return :pushing if image_statuses.any? { |status| status == :pushing }
+      return :not_pushed if image_statuses.any? { |status| status == :not_pushed }
+      :pushed
+    rescue Exception => e
+      error = humanize_error(e.message)
+      return error
+    end
   end
 
   def to_polymorphic_path_param(polymorphic_path_extras)
-- 
1.7.6.5




More information about the aeolus-devel mailing list