Skip to content
Snippets Groups Projects
Commit 8c4b9364 authored by Luca Bigliardi's avatar Luca Bigliardi
Browse files

HooksMaster: logging hooks in RunPhase


Extend RunPhase so it will log hooks results in POST phase.

Signed-off-by: default avatarLuca Bigliardi <shammash@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 035a7783
No related branches found
No related tags found
No related merge requests found
...@@ -357,24 +357,33 @@ class HooksMaster(object): ...@@ -357,24 +357,33 @@ class HooksMaster(object):
results = self._RunWrapper(nodes, hpath, phase) results = self._RunWrapper(nodes, hpath, phase)
else: else:
results = self._RunWrapper(self.node_list[phase], hpath, phase) results = self._RunWrapper(self.node_list[phase], hpath, phase)
if phase == constants.HOOKS_PHASE_PRE: errs = []
errs = [] if not results:
if not results: msg = "Communication Failure"
raise errors.HooksFailure("Communication failure") if phase == constants.HOOKS_PHASE_PRE:
for node_name in results: raise errors.HooksFailure(msg)
res = results[node_name] else:
if res.offline: self.lu.LogWarning(msg)
continue for node_name in results:
msg = res.RemoteFailMsg() res = results[node_name]
if msg: if res.offline:
self.lu.LogWarning("Communication failure to node %s: %s", continue
node_name, msg) msg = res.RemoteFailMsg()
continue if msg:
for script, hkr, output in res.payload: self.lu.LogWarning("Communication failure to node %s: %s",
if hkr == constants.HKR_FAIL: node_name, msg)
continue
for script, hkr, output in res.payload:
if hkr == constants.HKR_FAIL:
if phase == constants.HOOKS_PHASE_PRE:
errs.append((node_name, script, output)) errs.append((node_name, script, output))
if errs: else:
raise errors.HooksAbort(errs) if not output:
output = "(no output)"
self.lu.LogWarning("On %s script %s failed, output: %s" %
(node_name, script, output))
if errs and phase == constants.HOOKS_PHASE_PRE:
raise errors.HooksAbort(errs)
return results return results
def RunConfigUpdate(self): def RunConfigUpdate(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment