gnt-cluster repair-disk-sizes repairs spindles too
authorBernardo Dal Seno <bdalseno@google.com>
Thu, 23 May 2013 00:03:13 +0000 (02:03 +0200)
committerBernardo Dal Seno <bdalseno@google.com>
Tue, 28 May 2013 09:45:59 +0000 (11:45 +0200)
When exclusive storage is active, any wrong or missing spindles information
in disks gets updated too.

Signed-off-by: Bernardo Dal Seno <bdalseno@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

lib/cmdlib/cluster.py
lib/opcodes.py
man/gnt-cluster.rst

index 1959963..f418b5a 100644 (file)
@@ -528,6 +528,9 @@ class LUClusterRepairDiskSizes(NoHooksLU):
       "Not owning correct locks"
     assert not self.owned_locks(locking.LEVEL_NODE)
 
+    es_flags = rpc.GetExclusiveStorageForNodeNames(self.cfg,
+                                                   per_node_disks.keys())
+
     changed = []
     for node, dskl in per_node_disks.items():
       newl = [v[2].Copy() for v in dskl]
@@ -554,7 +557,7 @@ class LUClusterRepairDiskSizes(NoHooksLU):
                           " dimension information, ignoring", idx,
                           instance.name)
           continue
-        (size, _) = dimensions
+        (size, spindles) = dimensions
         if not isinstance(size, (int, long)):
           self.LogWarning("Disk %d of instance %s did not return valid"
                           " size information, ignoring", idx, instance.name)
@@ -566,10 +569,22 @@ class LUClusterRepairDiskSizes(NoHooksLU):
                        instance.name, disk.size, size)
           disk.size = size
           self.cfg.Update(instance, feedback_fn)
-          changed.append((instance.name, idx, size))
+          changed.append((instance.name, idx, "size", size))
+        if es_flags[node]:
+          if spindles is None:
+            self.LogWarning("Disk %d of instance %s did not return valid"
+                            " spindles information, ignoring", idx,
+                            instance.name)
+          elif disk.spindles is None or disk.spindles != spindles:
+            self.LogInfo("Disk %d of instance %s has mismatched spindles,"
+                         " correcting: recorded %s, actual %s",
+                         idx, instance.name, disk.spindles, spindles)
+            disk.spindles = spindles
+            self.cfg.Update(instance, feedback_fn)
+            changed.append((instance.name, idx, "spindles", disk.spindles))
         if self._EnsureChildSizes(disk):
           self.cfg.Update(instance, feedback_fn)
-          changed.append((instance.name, idx, disk.size))
+          changed.append((instance.name, idx, "size", disk.size))
     return changed
 
 
index ee4da31..918a273 100644 (file)
@@ -868,7 +868,7 @@ class OpClusterRepairDiskSizes(OpCode):
   Parameters: optional instances list, in case we want to restrict the
   checks to only a subset of the instances.
 
-  Result: a list of tuples, (instance, disk, new-size) for changed
+  Result: a list of tuples, (instance, disk, parameter, new-size) for changed
   configurations.
 
   In normal operation, the list should be empty.
@@ -880,9 +880,10 @@ class OpClusterRepairDiskSizes(OpCode):
   OP_PARAMS = [
     ("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
     ]
-  OP_RESULT = ht.TListOf(ht.TAnd(ht.TIsLength(3),
+  OP_RESULT = ht.TListOf(ht.TAnd(ht.TIsLength(4),
                                  ht.TItems([ht.TNonEmptyString,
                                             ht.TNonNegativeInt,
+                                            ht.TNonEmptyString,
                                             ht.TNonNegativeInt])))
 
 
index 4458e2b..2c1e2a4 100644 (file)
@@ -758,14 +758,15 @@ This command checks that the recorded size of the given instance's
 disks matches the actual size and updates any mismatches found.
 This is needed if the Ganeti configuration is no longer consistent
 with reality, as it will impact some disk operations. If no
-arguments are given, all instances will be checked.
+arguments are given, all instances will be checked. When exclusive
+storage is active, also spindles are updated.
 
 Note that only active disks can be checked by this command; in case
 a disk cannot be activated it's advised to use
 **gnt-instance activate-disks \--ignore-size ...** to force
 activation without regard to the current size.
 
-When the all disk sizes are consistent, the command will return no
+When all the disk sizes are consistent, the command will return no
 output. Otherwise it will log details about the inconsistencies in
 the configuration.