Fix checks in LUSetNodeParms for the master node
authorIustin Pop <iustin@google.com>
Fri, 14 Aug 2009 09:07:06 +0000 (11:07 +0200)
committerIustin Pop <iustin@google.com>
Fri, 14 Aug 2009 09:26:46 +0000 (11:26 +0200)
There was a check already in the LU for the master node, however is
wasn't correct. This patch disallows any role changes on the master node
via LUSetNodeParms (and as this LU can't change anything else, it
practically prevents it from touching the master node).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/cmdlib.py

index 78a379d..4a36d5b 100644 (file)
@@ -2499,12 +2499,16 @@ class LUSetNodeParams(LogicalUnit):
     """
     node = self.node = self.cfg.GetNodeInfo(self.op.node_name)
 
+    if (self.op.master_candidate is not None or
+        self.op.drained is not None or
+        self.op.offline is not None):
+      # we can't change the master's node flags
+      if self.op.node_name == self.cfg.GetMasterNode():
+        raise errors.OpPrereqError("The master role can be changed"
+                                   " only via masterfailover")
+
     if ((self.op.master_candidate == False or self.op.offline == True or
          self.op.drained == True) and node.master_candidate):
-      # we will demote the node from master_candidate
-      if self.op.node_name == self.cfg.GetMasterNode():
-        raise errors.OpPrereqError("The master node has to be a"
-                                   " master candidate, online and not drained")
       cp_size = self.cfg.GetClusterInfo().candidate_pool_size
       num_candidates, _ = self.cfg.GetMasterCandidateStats()
       if num_candidates <= cp_size: