Commit c69b147d authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

Report missing spindles in the configuration



cfgupgrade and cluster-verify run a check for missing spindles in disk
configuration when exclusive storage is enabled. The check in cfgupgrade
may give false positives due to the complexity of getting the correct value
of exclusive_storage for each instance.
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 577edf04
......@@ -1900,17 +1900,26 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
utils.CommaJoin(inst_config.secondary_nodes),
code=self.ETYPE_WARNING)
if inst_config.disk_template not in constants.DTS_EXCL_STORAGE:
# Disk template not compatible with exclusive_storage: no instance
# node should have the flag set
es_flags = rpc.GetExclusiveStorageForNodeNames(self.cfg,
inst_config.all_nodes)
es_nodes = [n for (n, es) in es_flags.items()
if es]
_ErrorIf(es_nodes, constants.CV_EINSTANCEUNSUITABLENODE, instance,
"instance has template %s, which is not supported on nodes"
" that have exclusive storage set: %s",
inst_config.disk_template, utils.CommaJoin(es_nodes))
es_flags = rpc.GetExclusiveStorageForNodeNames(self.cfg,
inst_config.all_nodes)
if any(es_flags.values()):
if inst_config.disk_template not in constants.DTS_EXCL_STORAGE:
# Disk template not compatible with exclusive_storage: no instance
# node should have the flag set
es_nodes = [n
for (n, es) in es_flags.items()
if es]
self._Error(constants.CV_EINSTANCEUNSUITABLENODE, instance,
"instance has template %s, which is not supported on nodes"
" that have exclusive storage set: %s",
inst_config.disk_template, utils.CommaJoin(es_nodes))
for (idx, disk) in enumerate(inst_config.disks):
_ErrorIf(disk.spindles is None,
constants.CV_EINSTANCEMISSINGCFGPARAMETER, instance,
"number of spindles not configured for disk %s while"
" exclusive storage is enabled, try running"
" gnt-cluster repair-disk-sizes",
idx)
if inst_config.disk_template in constants.DTS_INT_MIRROR:
instance_nodes = utils.NiceSort(inst_config.all_nodes)
......
......@@ -1589,6 +1589,9 @@ CV_EINSTANCEPOLICY = \
CV_EINSTANCEUNSUITABLENODE = \
(CV_TINSTANCE, "EINSTANCEUNSUITABLENODE",
"Instance running on nodes that are not suitable for it")
CV_EINSTANCEMISSINGCFGPARAMETER = \
(CV_TINSTANCE, "EINSTANCEMISSINGCFGPARAMETER",
"A configuration parameter for an instance is missing")
CV_ENODEDRBD = \
(CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
CV_ENODEDRBDVERSION = \
......
......@@ -155,12 +155,31 @@ def UpgradeGroups(config_data):
UpgradeIPolicy(ipolicy, cl_ipolicy, True)
def GetExclusiveStorageValue(config_data):
"""Return a conservative value of the exclusive_storage flag.
Return C{True} if the cluster or at least a nodegroup have the flag set.
"""
ret = False
cluster = config_data["cluster"]
ndparams = cluster.get("ndparams")
if ndparams is not None and ndparams.get("exclusive_storage"):
ret = True
for group in config_data["nodegroups"].values():
ndparams = group.get("ndparams")
if ndparams is not None and ndparams.get("exclusive_storage"):
ret = True
return ret
def UpgradeInstances(config_data):
network2uuid = dict((n["name"], n["uuid"])
for n in config_data["networks"].values())
if "instances" not in config_data:
raise Error("Can't find the 'instances' key in the configuration!")
missing_spindles = False
for instance, iobj in config_data["instances"].items():
for nic in iobj["nics"]:
name = nic.get("network", None)
......@@ -182,6 +201,17 @@ def UpgradeInstances(config_data):
" from '%s' to '%s'",
instance, idx, current, expected)
dobj["iv_name"] = expected
if not "spindles" in dobj:
missing_spindles = True
if GetExclusiveStorageValue(config_data) and missing_spindles:
# We cannot be sure that the instances that are missing spindles have
# exclusive storage enabled (the check would be more complicated), so we
# give a noncommittal message
logging.warning("Some instance disks could be needing to update the"
" spindles parameter; you can check by running"
" 'gnt-cluster verify', and fix any problem with"
" 'gnt-cluster repair-disk-sizes'")
def UpgradeRapiUsers():
......
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