From 3d9eb52bf6112951d63202957e18678e7e917b19 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Thu, 1 Oct 2009 17:29:29 +0100 Subject: [PATCH] LUSetNodeParams: autopromote self when needed If we're de-offlining or de-draining a node we need to promote it to MC if we have not enough, or the config will be corrupt. Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Olivier Tharan <olive@google.com> --- lib/cmdlib.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 3ae94b6e1..c7e1ec161 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2979,6 +2979,7 @@ class LUSetNodeParams(LogicalUnit): # Boolean value that tells us whether we're offlining or draining the node offline_or_drain = self.op.offline == True or self.op.drained == True + deoffline_or_drain = self.op.offline == False or self.op.drained == False if (node.master_candidate and (self.op.master_candidate == False or offline_or_drain)): @@ -3002,6 +3003,13 @@ class LUSetNodeParams(LogicalUnit): raise errors.OpPrereqError("Node '%s' is offline or drained, can't set" " to master_candidate" % node.name) + # If we're being deofflined/drained, we'll MC ourself if needed + if (deoffline_or_drain and not offline_or_drain and not + self.op.master_candidate == True): + self.op.master_candidate = _DecideSelfPromotion(self) + if self.op.master_candidate: + self.LogInfo("Autopromoting node to master candidate") + return def Exec(self, feedback_fn): -- GitLab