From 22d9752a08107a171e94564615c6d6d23f37ebae Mon Sep 17 00:00:00 2001
From: Bernardo Dal Seno <bdalseno@google.com>
Date: Sun, 13 Jan 2013 16:07:19 +0100
Subject: [PATCH] cluster-verify checks uniformity of exclusive_storage flag

The value of the flag should be the same for nodes within the same group.

Signed-off-by: Bernardo Dal Seno <bdalseno@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/cmdlib.py    | 15 +++++++++++++++
 lib/constants.py |  4 ++++
 2 files changed, 19 insertions(+)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index ca0650a15..c0062c9c4 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -3371,6 +3371,21 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
           nimg.sbp[pnode] = []
         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
+    if compat.any(es_flags.values()):
+      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/constants.py b/lib/constants.py
index 9203bf3de..e0b5daeb3 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -1432,6 +1432,7 @@ VERIFY_OPTIONAL_CHECKS = compat.UniqueFrozenset([VERIFY_NPLUSONE_MEM])
 
 # Cluster Verify error classes
 CV_TCLUSTER = "cluster"
+CV_TGROUP = "group"
 CV_TNODE = "node"
 CV_TINSTANCE = "instance"
 
@@ -1450,6 +1451,9 @@ 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_EINSTANCEBADNODE = \
   (CV_TINSTANCE, "EINSTANCEBADNODE",
    "Instance marked as running lives on an offline node")
-- 
GitLab