Commit c957326e authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Fix execution order in LUOobCommand causing wrongly setup node list

In commit bfceedbe

 a check was added to put the master at the end or
skip it completely. While this functionality works, it was done at the
wrong point because node_names was already processed to a node list
without this checks. The Exec method if the LU just used that node list.

To overcome this situation we correct the node_names before the node
list is generated.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 25bd815c
......@@ -3228,42 +3228,43 @@ class LUOobCommand(NoHooksLU):
"""
self.nodes = []
master_node = self.cfg.GetMasterNode()
for node_name in self.op.node_names:
node = self.cfg.GetNodeInfo(node_name)
if node is None:
raise errors.OpPrereqError("Node %s not found" % node_name,
errors.ECODE_NOENT)
else:
self.nodes.append(node)
if (not self.op.ignore_status and
(self.op.command == constants.OOB_POWER_OFF and not node.offline)):
raise errors.OpPrereqError(("Cannot power off node %s because it is"
" not marked offline") % node_name,
errors.ECODE_STATE)
self.master_node = self.cfg.GetMasterNode()
if self.op.command in (constants.OOB_POWER_OFF, constants.OOB_POWER_CYCLE):
# This does two things, it checks if master is in the list and if so and
# force_master is set it puts it to the end so the master is done last
try:
self.op.node_names.remove(master_node)
self.op.node_names.remove(self.master_node)
except ValueError:
pass
else:
if self.op.force_master:
self.op.node_names.append(master_node)
self.op.node_names.append(self.master_node)
else:
self.LogWarning("Master %s was skipped, use the force master"
" option to operate on the master too",
master_node)
self.master_node)
if not self.op.node_names:
raise errors.OpPrereqError("No nodes left to operate on, aborting",
errors.ECODE_INVAL)
assert (master_node not in self.op.node_names or
self.op.node_names[-1] == master_node)
assert (self.master_node not in self.op.node_names or
self.op.node_names[-1] == self.master_node)
for node_name in self.op.node_names:
node = self.cfg.GetNodeInfo(node_name)
if node is None:
raise errors.OpPrereqError("Node %s not found" % node_name,
errors.ECODE_NOENT)
else:
self.nodes.append(node)
if (not self.op.ignore_status and
(self.op.command == constants.OOB_POWER_OFF and not node.offline)):
raise errors.OpPrereqError(("Cannot power off node %s because it is"
" not marked offline") % node_name,
errors.ECODE_STATE)
def ExpandNames(self):
"""Gather locks we need.
......@@ -3283,7 +3284,7 @@ class LUOobCommand(NoHooksLU):
"""Execute OOB and return result if we expect any.
"""
master_node = self.cfg.GetMasterNode()
master_node = self.master_node
ret = []
for node in self.nodes:
......
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