Browse Source

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)
tags/9.6.1
Thomas Herve 9 months ago
parent
commit
39e37c03d5
1 changed files with 2 additions and 4 deletions
  1. 2
    4
      tripleo_common/actions/ansible.py

+ 2
- 4
tripleo_common/actions/ansible.py View File

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

Loading…
Cancel
Save