Commit b423c513 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Remove restrictive hook node list check

Commit dd7f6776 added a restrictive check for the node lists returned
by BuildHooksEnv, leading to errors with some LUs, one of which was
fixed in commit 0dfa2c22

. As it turns out, other LUs have similar
issues, some not easy to fix. This patch disables the restrictive check
until the BuildHooksEnv functions can be split into one part generating
the actual environment and one generating the node lists.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 562be46d
......@@ -428,7 +428,7 @@ class HooksMaster(object): = lu
self.op = lu.op
self.pre_env = None
self.pre_nodes = None
self.post_nodes = None
def _BuildEnv(self, phase):
"""Compute the environment and the target nodes.
......@@ -526,14 +526,12 @@ class HooksMaster(object):
(env, node_list_pre, node_list_post) = self._BuildEnv(phase)
if nodes is None:
if phase == constants.HOOKS_PHASE_PRE:
self.pre_nodes = (node_list_pre, node_list_post)
nodes = node_list_pre
self.post_nodes = node_list_post
elif self.post_nodes is None:
raise AssertionError("Pre-phase must be run before post-phase")
elif phase == constants.HOOKS_PHASE_POST:
post_nodes = (node_list_pre, node_list_post)
assert self.pre_nodes == post_nodes, \
("Node lists returned for post-phase hook don't match pre-phase"
" lists (pre %s, post %s)" % (self.pre_nodes, post_nodes))
nodes = node_list_post
nodes = self.post_nodes
raise AssertionError("Unknown phase '%s'" % phase)
......@@ -379,11 +379,12 @@ class TestHooksRunnerEnv(unittest.TestCase):
def testConflict(self):
for name in ["DATA_DIR", "OP_CODE"]: = { name: "value" }
# Test using a clean HooksMaster instance
hm = mcpu.HooksMaster(self._HooksRpc,
for phase in [constants.HOOKS_PHASE_PRE, constants.HOOKS_PHASE_POST]:
# Test using a clean HooksMaster instance
self.assertRaises(AssertionError, hm.RunPhase, phase)
self.assertRaises(IndexError, self._rpcs.pop)
def testNoNodes(self):
......@@ -415,6 +416,11 @@ class TestHooksRunnerEnv(unittest.TestCase):
self.assertRaises(IndexError, self._rpcs.pop)
def testNoPreBeforePost(self): = {}
if __name__ == '__main__':
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