Commit 3d9eb52b authored by Guido Trotter's avatar Guido Trotter
Browse files

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: default avatarGuido Trotter <>
Reviewed-by: default avatarOlivier Tharan <>
parent 6d7e1f20
......@@ -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" %
# 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")
def Exec(self, feedback_fn):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment