[PATCH conductor] BZ 800837 - Vanished instances are now included in failed?

Matt Wagner matt.wagner at redhat.com
Wed Mar 14 19:21:30 UTC 2012


The failed? method on an instance was not considering STATE_VANISHED
to be a failure, causing (among other things) the 'error' icon to not
display in table view. This fixes this, and has the incidental benefit
of making the code slightly more compact by using the existing FAILED_STATES
constant instead of a series of checks.

Resolves https://bugzilla.redhat.com/show_bug.cgi?id=800837
---
 src/app/controllers/pools_controller.rb |    2 +-
 src/app/models/instance.rb              |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/app/controllers/pools_controller.rb b/src/app/controllers/pools_controller.rb
index 3529b7d..11b86aa 100644
--- a/src/app/controllers/pools_controller.rb
+++ b/src/app/controllers/pools_controller.rb
@@ -313,7 +313,7 @@ class PoolsController < ApplicationController
 
   def statistics
     instances = current_user.owned_instances
-    failed_instances = instances.select {|instance| instance.state == Instance::STATE_CREATE_FAILED || instance.state == Instance::STATE_ERROR}
+    failed_instances = instances.failed
     @statistics = {
               :pools_in_use => @user_pools.select { |pool| pool.instances.pending.count > 0 || pool.instances.deployed.count > 0 }.count,
               :deployments => current_user.deployments.count,
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index 967b26c..f074150 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -344,7 +344,7 @@ class Instance < ActiveRecord::Base
   end
 
   def failed?
-    state == Instance::STATE_CREATE_FAILED || state == Instance::STATE_ERROR
+    FAILED_STATES.include?(state)
   end
 
   def requires_config_server?
-- 
1.7.7.6




More information about the aeolus-devel mailing list