Gracefully handle degraded instances in verification
authorKlaus Aehlig <aehlig@google.com>
Thu, 30 Jan 2014 15:30:00 +0000 (16:30 +0100)
committerKlaus Aehlig <aehlig@google.com>
Thu, 30 Jan 2014 16:28:41 +0000 (17:28 +0100)
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>

lib/cmdlib/cluster.py

index 4183825..cf020c2 100644 (file)
@@ -2618,6 +2618,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
     node_disks = {}
     node_disks_devonly = {}
     diskless_instances = set()
+    nodisk_instances = set()
     diskless = constants.DT_DISKLESS
 
     for nuuid in node_uuids:
@@ -2630,6 +2631,8 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
                for disk in instanceinfo[inst_uuid].disks]
 
       if not disks:
+        nodisk_instances.update(uuid for uuid in node_inst_uuids
+                                if instanceinfo[uuid].disk_template != diskless)
         # No need to collect data
         continue
 
@@ -2687,6 +2690,10 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
     for inst_uuid in diskless_instances:
       assert inst_uuid not in instdisk
       instdisk[inst_uuid] = {}
+    # ...and disk-full instances that happen to have no disks
+    for inst_uuid in nodisk_instances:
+      assert inst_uuid not in instdisk
+      instdisk[inst_uuid] = {}
 
     assert compat.all(len(statuses) == len(instanceinfo[inst].disks) and
                       len(nuuids) <= len(instanceinfo[inst].all_nodes) and