Add error code for temporary lack of resources
authorMichael Hanselmann <hansmi@google.com>
Tue, 4 Dec 2012 15:17:05 +0000 (16:17 +0100)
committerMichael Hanselmann <hansmi@google.com>
Fri, 7 Dec 2012 12:47:08 +0000 (13:47 +0100)
When an instance creation uses opportunistic locks, the iallocator might
not be able to find an allocation solution if not enough node locks (or
a suboptimal subset thereof) were acquired. As per the design document
<doc/design-opportunistic-locking.rst> a new error code denoting
temporary failures is added.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/cmdlib.py
lib/errors.py

index 3aed190..d29631a 100644 (file)
@@ -9957,10 +9957,17 @@ class LUInstanceCreate(LogicalUnit):
     ial.Run(self.op.iallocator)
 
     if not ial.success:
+      # When opportunistic locks are used only a temporary failure is generated
+      if self.op.opportunistic_locking:
+        ecode = errors.ECODE_TEMP_NORES
+      else:
+        ecode = errors.ECODE_NORES
+
       raise errors.OpPrereqError("Can't compute nodes using"
                                  " iallocator '%s': %s" %
                                  (self.op.iallocator, ial.info),
-                                 errors.ECODE_NORES)
+                                 ecode)
+
     self.op.pnode = ial.result[0]
     self.LogInfo("Selected nodes for instance %s via iallocator %s: %s",
                  self.op.instance_name, self.op.iallocator,
index 3d2a33d..7fc3efe 100644 (file)
@@ -30,6 +30,9 @@ ECODE_RESOLVER = "resolver_error"
 #: Not enough resources (iallocator failure, disk space, memory, etc.)
 ECODE_NORES = "insufficient_resources"
 
+#: Temporarily out of resources; operation can be tried again
+ECODE_TEMP_NORES = "insufficient_resources"
+
 #: Wrong arguments (at syntax level)
 ECODE_INVAL = "wrong_input"
 
@@ -55,6 +58,7 @@ ECODE_ENVIRON = "environment_error"
 ECODE_ALL = frozenset([
   ECODE_RESOLVER,
   ECODE_NORES,
+  ECODE_TEMP_NORES,
   ECODE_INVAL,
   ECODE_STATE,
   ECODE_NOENT,