Try to early terminate streaming on ansible errors

Currently when ansible has an error when trying to run a command or
shell task the command module has no chance to send any console
log. Thus zuul_stream doesn't terminate by itself and gets killed
after a timeout of 30s. As a try to fix this zuul_console sends
periodically a notice about the not found logfile. When requesting the
streamer to exit it can check then if there is still no console file
and exit by itself without needing to timeout.

Change-Id: I42bc05b0d2c530fbfc00c6295da24d18a6ec6435
This commit is contained in:
Tobias Henkel 2017-08-04 21:07:24 +02:00
parent f5cdd49fc3
commit 09fabaf722
2 changed files with 9 additions and 0 deletions

View File

@ -98,6 +98,7 @@ class CallbackModule(default.CallbackModule):
self._daemon_running = False
self._play = None
self._streamers = []
self._streamers_stop = False
self.configure_logger()
self._items_done = False
self._deferred_result = None
@ -142,6 +143,11 @@ class CallbackModule(default.CallbackModule):
for line in linesplit(s):
if "[Zuul] Task exit code" in line:
return
elif self._streamers_stop and "[Zuul] Log not found" in line:
return
elif "[Zuul] Log not found" in line:
# don't output this line
pass
else:
ts, ln = line.split(' | ', 1)
ln = ln.strip()
@ -223,6 +229,7 @@ class CallbackModule(default.CallbackModule):
self._streamers.append(streamer)
def _stop_streamers(self):
self._streamers_stop = True
while True:
if not self._streamers:
break
@ -231,6 +238,7 @@ class CallbackModule(default.CallbackModule):
if streamer.is_alive():
msg = "[Zuul] Log Stream did not terminate"
self._log(msg, job=True, executor=True)
self._streamers_stop = False
def _process_result_for_localhost(self, result, is_task=True):
result_dict = dict(result._result)

View File

@ -185,6 +185,7 @@ class Server(object):
console = self.chunkConsole(conn, log_uuid)
if console:
break
conn.send('[Zuul] Log not found\n')
time.sleep(0.5)
while True:
if self.followConsole(console, conn):