Commit 4f5c2533 authored by Adeodato Simo's avatar Adeodato Simo
Browse files

Fix gnt-cluster verify with diskless instances



`gnt-cluster verify` was failing with KeyError if there was any
diskless instance in the cluster. This was because _CollectDiskInfo()
was not including these instances in the returned dictionary, but they
were expected to be present in LUVerifyCluster.Exec().

With this commit, we ensure that the dictionary returned by _CollectDiskInfo
includes entries for diskless instances as well.
Signed-off-by: default avatarAdeodato Simo <dato@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 5fd6b694
......@@ -39,6 +39,7 @@ import OpenSSL
import socket
import tempfile
import shutil
import itertools
from ganeti import ssh
from ganeti import utils
......@@ -1920,12 +1921,16 @@ class LUVerifyCluster(LogicalUnit):
node_disks = {}
node_disks_devonly = {}
diskless_instances = set()
diskless = constants.DT_DISKLESS
for nname in nodelist:
node_instances = list(itertools.chain(node_image[nname].pinst,
node_image[nname].sinst))
diskless_instances.update(inst for inst in node_instances
if instanceinfo[inst].disk_template == diskless)
disks = [(inst, disk)
for instlist in [node_image[nname].pinst,
node_image[nname].sinst]
for inst in instlist
for inst in node_instances
for disk in instanceinfo[inst].disks]
if not disks:
......@@ -1972,6 +1977,11 @@ class LUVerifyCluster(LogicalUnit):
for ((inst, _), status) in zip(disks, data):
instdisk.setdefault(inst, {}).setdefault(nname, []).append(status)
# Add empty entries for diskless instances.
for inst in diskless_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)
for inst, nnames in instdisk.items()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment