On Tue, Apr 21, 2015 at 06:31:32PM +0200, 'Klaus Aehlig' via ganeti-devel wrote:
While already checked and taken into account by htools, in particular
hcheck, quite a few people rely on 'gnt-cluster verify' to warn about
all issues with the cluster. So add a test here as well.

Signed-off-by: Klaus Aehlig <[email protected]>
---
lib/cmdlib/cluster/verify.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

diff --git a/lib/cmdlib/cluster/verify.py b/lib/cmdlib/cluster/verify.py
index b0606aa..e43fb2a 100644
--- a/lib/cmdlib/cluster/verify.py
+++ b/lib/cmdlib/cluster/verify.py
@@ -1759,6 +1759,33 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
    if n_drained:
      feedback_fn("  - NOTICE: %d drained node(s) found." % n_drained)

+  def _VerifyExclusionTags(self, nodename, pinst, ctags):
+    """Verify that all instances have different exclusion tags.
+
+    @type nodename: string
+    @param nodename: the name of the node for which the check is done
+    @type pinst: list of string
+    @param pinst: list of UUIDs of those instances having the given node
+        as primary node
+    @type ctags: list of string
+    @param ctags: tags of the cluster
+
+    """
+    exclusion_prefixes = utils.GetExclusionPrefixes(ctags)
+    tags_seen = set([])
+    conflicting_tags = set([])
+    for iuuid in pinst:
+      itags = set([tag for tag in self.my_inst_info[iuuid].tags
+                   if utils.IsGoodTag(exclusion_prefixes, tag)])
+      conflicts = itags.intersection(itags)

This was probably meant to be itags.intersection(tag_seen)

+      if len(conflicts) > 0:
+        conflicting_tags = conflicting_tags.union(conflicts)
+      tags_seen = tags_seen.union(itags)
+
+    self._ErrorIf(len(conflicting_tags) > 0, constants.CV_EEXTAGS, nodename,
+                  "Tags where there is more than one instance: %s",
+                  list(conflicting_tags), code=constants.CV_WARNING)
+
  def Exec(self, feedback_fn):
    """Verify integrity of the node group, performing various test on nodes.

@@ -2098,6 +2125,8 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
          self._ErrorIf(not test, constants.CV_ENODEORPHANINSTANCE, node_i.name,
                        "node is running unknown instance %s", inst_uuid)

+        self._VerifyExclusionTags(node_i.name, nimg.pinst, cluster.tags)
+
    self._VerifyGroupDRBDVersion(all_nvinfo)
    self._VerifyGroupLVM(node_image, vg_name)

--
2.2.0.rc0.207.ga3a616c


Rest LGTM

Reply via email to