This patch uses STATE_ERROR instead of STATE_CREATE_FAILED for the
instance since condor uses a generic 'held' state to indicate an error.
At this time we are not parsing out the error information so really we
are setting a generic error about the instance rather than the special
case error of CREATE_FAILED.

Obviously we need better error messages and states but for now this at
least more accurately reflects the nature of the state.

Signed-off-by: Ian Main <[email protected]>
---
 src/app/models/instance.rb  |    4 +++-
 src/app/util/condormatic.rb |    2 +-
 src/dbomatic/dbomatic       |   14 +++++++++++---
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index 5f0c5f2..5ede90e 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -53,9 +53,11 @@ class Instance < ActiveRecord::Base
   STATE_SHUTTING_DOWN  = "shutting_down"
   STATE_STOPPED        = "stopped"
   STATE_CREATE_FAILED  = "create_failed"
+  STATE_ERROR          = "error"
 
   STATES = [STATE_NEW, STATE_PENDING, STATE_RUNNING,
-             STATE_SHUTTING_DOWN, STATE_STOPPED, STATE_CREATE_FAILED]
+             STATE_SHUTTING_DOWN, STATE_STOPPED, STATE_CREATE_FAILED,
+             STATE_ERROR]
 
   SEARCHABLE_COLUMNS = %w(name state)
 
diff --git a/src/app/util/condormatic.rb b/src/app/util/condormatic.rb
index 0eac6cb..9b678ee 100644
--- a/src/app/util/condormatic.rb
+++ b/src/app/util/condormatic.rb
@@ -106,7 +106,7 @@ def condor_to_instance_state(state_val)
     when '4'
       return Instance::STATE_STOPPED
     when '5'
-      return Instance::STATE_CREATE_FAILED
+      return Instance::STATE_ERROR
     when '6'
       return Instance::STATE_CREATE_FAILED
   else
diff --git a/src/dbomatic/dbomatic b/src/dbomatic/dbomatic
index e013a5c..083d294 100755
--- a/src/dbomatic/dbomatic
+++ b/src/dbomatic/dbomatic
@@ -144,14 +144,22 @@ class CondorEventLog < Nokogiri::XML::SAX::Document
       # However, it's not a state that we care to export to users, but it's
       # also not an error, so we just silently ignore it.
     elsif @trigger_type == "ULOG_JOB_HELD"
-      # we failed to start the instance
+      # The job has some error condition.
+      #
       # FIXME: if this happens, we probably want to add the HoldReason field
       # to the database so we can display it to the user
       # FIXME: we also may want to delete this job from condor, depending
       # on the error.  For instance, if you are trying to start an instance
       # with a mismatched image and hardwareprofile architecture, the only
-      # reasonable way out is to create a new instance.  Needs thought
-      inst.state = Instance::STATE_CREATE_FAILED
+      # reasonable way out is to create a new instance.  Needs thought.
+      #  - I've added a condormatic_instance_reset_error() method to reset
+      #    error conditions such as this.  In the future we should give 
different
+      #    options based on the error condition.
+      # FIXME: Right now we don't parse out the HoldReason (or HoldReasonCode)
+      # so for now I'm going to set this to STATE_ERROR as there are multiple
+      # possible reasons for going into the 'held' state.
+
+      inst.state = Instance::STATE_ERROR
     else
       @logger.info "Unexpected trigger type #...@trigger_type}, not updating 
instance state"
       return
-- 
1.7.2.3

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to