From 97c61d46ffa3a56afbbfc60ea92128dc456f4592 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 14 Aug 2009 11:07:06 +0200 Subject: [PATCH] Fix checks in LUSetNodeParms for the master node 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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 78a379ddf..4a36d5bfb 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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: -- GitLab