Don't accumulate ansible output uselessly

To not overload mistral, we often call the ansible playbook action with
"trash_output". When that's the case, we can discard stdout immediately,
instead of accumulating it and then discarding it.

Change-Id: Ia3d05d716a8e0a1665f9b9310f7d25370bbcdf8d
(cherry picked from commit 37dee4aa03)
This commit is contained in:
Thomas Herve 2018-11-28 11:37:06 +01:00 committed by James Slagle
parent 99c29dd7b5
commit 39e37c03d5
1 changed files with 2 additions and 4 deletions

View File

@ -563,7 +563,8 @@ class AnsiblePlaybookAction(base.TripleOAction):
lines = [] lines = []
for line in iter(process.stdout.readline, b''): for line in iter(process.stdout.readline, b''):
lines.append(line) lines.append(line)
stdout.append(line) if not self.trash_output:
stdout.append(line)
if time.time() - start > 30: if time.time() - start > 30:
self.post_message(queue, ''.join(lines)) self.post_message(queue, ''.join(lines))
lines = [] lines = []
@ -575,9 +576,6 @@ class AnsiblePlaybookAction(base.TripleOAction):
# stdout we don't know the difference. To keep the return dict # stdout we don't know the difference. To keep the return dict
# similar there is an empty stderr. We can use the return code # similar there is an empty stderr. We can use the return code
# to determine if there was an error. # to determine if there was an error.
if self.trash_output:
stdout = []
stderr = ""
return {"stdout": "".join(stdout), "returncode": returncode, return {"stdout": "".join(stdout), "returncode": returncode,
"stderr": ""} "stderr": ""}