From 3697def03c4778bd13f365e882e1131cb1e3e09b Mon Sep 17 00:00:00 2001 From: Bernardo Dal Seno <bdalseno@google.com> Date: Fri, 1 Feb 2013 16:31:43 +0100 Subject: [PATCH] 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: Bernardo Dal Seno <bdalseno@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/cmdlib.py | 11 ----------- lib/config.py | 4 ++++ lib/constants.py | 3 --- test/py/ganeti.config_unittest.py | 25 ++++++++++++++++++++++++- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 622375fdd..1bccf4a39 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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 diff --git a/lib/config.py b/lib/config.py index eb37c710f..5a882da5e 100644 --- a/lib/config.py +++ b/lib/config.py @@ -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() diff --git a/lib/constants.py b/lib/constants.py index 94c508025..3a5634f32 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -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 = \ diff --git a/test/py/ganeti.config_unittest.py b/test/py/ganeti.config_unittest.py index 112cdf248..da82fc0bd 100755 --- a/test/py/ganeti.config_unittest.py +++ b/test/py/ganeti.config_unittest.py @@ -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 -- GitLab