(2.9) Gracefully handle degraded instances in verification
authorKlaus Aehlig <aehlig@google.com>
Thu, 30 Jan 2014 15:30:00 +0000 (16:30 +0100)
committerDimitris Aragiorgis <dimara@grnet.gr>
Thu, 27 Mar 2014 08:01:06 +0000 (10:01 +0200)
The current code assumes that every instance either is of type
diskless or has at least one disk. However, with the option to
remove individual disk degraded 0-disk non-diskless instances
can occur. While such instances usually are not useful, Ganeti
still should be operational in their presence.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

lib/cmdlib/cluster.py

index d3c5aae..f0da68c 100644 (file)
@@ -2350,6 +2350,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
     node_disks = {}
     node_disks_devonly = {}
     diskless_instances = set()
+    nodisk_instances = set()
     diskless = constants.DT_DISKLESS
 
     for nname in nodelist:
@@ -2362,6 +2363,8 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
                for disk in instanceinfo[inst].disks]
 
       if not disks:
+        nodisk_instances.update(inst for inst in node_instances
+                                if instanceinfo[inst].disk_template != diskless)
         # No need to collect data
         continue
 
@@ -2416,6 +2419,10 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
     for inst in diskless_instances:
       assert inst not in instdisk
       instdisk[inst] = {}
+    # ...and disk-full instances that happen to have no disks
+    for inst in nodisk_instances:
+      assert inst not in instdisk
+      instdisk[inst] = {}
 
     assert compat.all(len(statuses) == len(instanceinfo[inst].disks) and
                       len(nnames) <= len(instanceinfo[inst].all_nodes) and