Commit 3697def0 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

Moved uniformity check for exclusive_storage flag



Cluster-verify used to check that the value of exclusive_storage is uniform
within node groups. Now, it's impossible to change the flag for a single
node, so that check has been removed and an equivalent one has been added
in ConfigWriter.VerifyConfig(). Unit test provided. The unit test covers
only the new check, not the whole VerifyConfig method.
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 250a9404
......@@ -3498,22 +3498,11 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
nimg.sbp[pnode].append(instance)
 
es_flags = rpc.GetExclusiveStorageForNodeNames(self.cfg, self.my_node_names)
es_unset_nodes = []
# The value of exclusive_storage should be the same across the group, so if
# it's True for at least a node, we act as if it were set for all the nodes
self._exclusive_storage = compat.any(es_flags.values())
if self._exclusive_storage:
node_verify_param[constants.NV_EXCLUSIVEPVS] = True
es_unset_nodes = [n for (n, es) in es_flags.items()
if not es]
if es_unset_nodes:
self._Error(constants.CV_EGROUPMIXEDESFLAG, self.group_info.name,
"The exclusive_storage flag should be uniform in a group,"
" but these nodes have it unset: %s",
utils.CommaJoin(utils.NiceSort(es_unset_nodes)))
self.LogWarning("Some checks required by exclusive storage will be"
" performed also on nodes with the flag unset")
 
# At this point, we have the in-memory data structures complete,
# except for the runtime information, which we'll gather next
......
......@@ -745,6 +745,10 @@ class ConfigWriter:
_helper("node %s" % node.name, "ndparams",
cluster.FillND(node, data.nodegroups[node.group]),
constants.NDS_PARAMETER_TYPES)
used_globals = constants.NDC_GLOBALS.intersection(node.ndparams)
if used_globals:
result.append("Node '%s' has some global parameters set: %s" %
(node.name, utils.CommaJoin(used_globals)))
# nodegroups checks
nodegroups_names = set()
......
......@@ -1455,9 +1455,6 @@ CV_ECLUSTERDANGLINGNODES = \
CV_ECLUSTERDANGLINGINST = \
(CV_TNODE, "ECLUSTERDANGLINGINST",
"Some instances have a non-existing primary node")
CV_EGROUPMIXEDESFLAG = \
(CV_TGROUP, "EGROUPMIXEDESFLAG",
"exclusive_storage flag is not uniform within the group")
CV_EGROUPDIFFERENTPVSIZE = \
(CV_TGROUP, "EGROUPDIFFERENTPVSIZE", "PVs in the group have different sizes")
CV_EINSTANCEBADNODE = \
......
......@@ -74,6 +74,8 @@ class TestConfigRunner(unittest.TestCase):
"""Initializes the cfg object"""
me = netutils.Hostname()
ip = constants.IP4_ADDRESS_LOCALHOST
# master_ip must not conflict with the node ip address
master_ip = "127.0.0.2"
cluster_config = objects.Cluster(
serial_no=1,
......@@ -87,7 +89,7 @@ class TestConfigRunner(unittest.TestCase):
tcpudp_port_pool=set(),
enabled_hypervisors=[constants.HT_FAKE],
master_node=me.name,
master_ip="127.0.0.1",
master_ip=master_ip,
master_netdev=constants.DEFAULT_BRIDGE,
cluster_name="cluster.local",
file_storage_dir="/tmp",
......@@ -426,6 +428,27 @@ class TestConfigRunner(unittest.TestCase):
finally:
node2.group = orig_group
def testVerifyConfig(self):
cfg = self._get_object()
errs = cfg.VerifyConfig()
self.assertFalse(errs)
node = cfg.GetNodeInfo(cfg.GetNodeList()[0])
key = list(constants.NDC_GLOBALS)[0]
node.ndparams[key] = constants.NDC_DEFAULTS[key]
errs = cfg.VerifyConfig()
self.assertTrue(len(errs) >= 1)
self.assertTrue(_IsErrorInList("has some global parameters set", errs))
del node.ndparams[key]
errs = cfg.VerifyConfig()
self.assertFalse(errs)
def _IsErrorInList(err_str, err_list):
return any(map(lambda e: err_str in e, err_list))
class TestTRM(unittest.TestCase):
EC_ID = 1
......
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