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 <>
Reviewed-by: default avatarIustin Pop <>
parent 5fd6b694
...@@ -39,6 +39,7 @@ import OpenSSL ...@@ -39,6 +39,7 @@ import OpenSSL
import socket import socket
import tempfile import tempfile
import shutil import shutil
import itertools
from ganeti import ssh from ganeti import ssh
from ganeti import utils from ganeti import utils
...@@ -1920,12 +1921,16 @@ class LUVerifyCluster(LogicalUnit): ...@@ -1920,12 +1921,16 @@ class LUVerifyCluster(LogicalUnit):
node_disks = {} node_disks = {}
node_disks_devonly = {} node_disks_devonly = {}
diskless_instances = set()
diskless = constants.DT_DISKLESS
for nname in nodelist: for nname in nodelist:
node_instances = list(itertools.chain(node_image[nname].pinst,
diskless_instances.update(inst for inst in node_instances
if instanceinfo[inst].disk_template == diskless)
disks = [(inst, disk) disks = [(inst, disk)
for instlist in [node_image[nname].pinst, for inst in node_instances
for inst in instlist
for disk in instanceinfo[inst].disks] for disk in instanceinfo[inst].disks]
if not disks: if not disks:
...@@ -1972,6 +1977,11 @@ class LUVerifyCluster(LogicalUnit): ...@@ -1972,6 +1977,11 @@ class LUVerifyCluster(LogicalUnit):
for ((inst, _), status) in zip(disks, data): for ((inst, _), status) in zip(disks, data):
instdisk.setdefault(inst, {}).setdefault(nname, []).append(status) 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 assert compat.all(len(statuses) == len(instanceinfo[inst].disks) and
len(nnames) <= len(instanceinfo[inst].all_nodes) len(nnames) <= len(instanceinfo[inst].all_nodes)
for inst, nnames in instdisk.items() 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