Fix bug in instance listing with orphan instances
authorIustin Pop <iustin@google.com>
Thu, 10 Mar 2011 11:37:16 +0000 (12:37 +0100)
committerIustin Pop <iustin@google.com>
Thu, 10 Mar 2011 14:30:02 +0000 (15:30 +0100)
Nodes can return unknown instances, so we shouldn't use the name as an
index without checking.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/cmdlib.py

index 67e9518..7a8091f 100644 (file)
@@ -3910,10 +3910,16 @@ class _InstanceQuery(_QueryBase):
           bad_nodes.append(name)
         elif result.payload:
           for inst in result.payload:
-            if all_info[inst].primary_node == name:
-              live_data.update(result.payload)
+            if inst in all_info:
+              if all_info[inst].primary_node == name:
+                live_data.update(result.payload)
+              else:
+                wrongnode_inst.add(inst)
             else:
-              wrongnode_inst.add(inst)
+              # orphan instance; we don't list it here as we don't
+              # handle this case yet in the output of instance listing
+              logging.warning("Orphan instance '%s' found on node %s",
+                              inst, name)
         # else no instance is alive
     else:
       live_data = {}