summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2018-12-06 16:29:44 +0000
committerMonty Taylor <mordred@inaugust.com>2018-12-06 20:57:20 +0000
commit43a03ef19f191a59370537858add32989ca19a89 (patch)
tree5fc1369b27eedbd097c643889daf1959c40e1330
parentddd8594a3c0ed7129a63d216db5cfe2fb359e8ce (diff)
Read old json data right before writing new data
Instead of holding the old log data in RAM for the entire run, just read it in right before writing the new data out. Change-Id: I9785475b8c876f2cf8e61c5926e6c9d43a432deb
Notes
Notes (review): Code-Review+2: Tobias Henkel <tobias.henkel@bmw.de> Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Code-Review+2: James E. Blair <corvus@inaugust.com> Workflow+1: James E. Blair <corvus@inaugust.com> Code-Review+2: Jeremy Stanley <fungi@yuggoth.org> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 06 Dec 2018 21:55:58 +0000 Reviewed-on: https://review.openstack.org/623245 Project: openstack-infra/zuul Branch: refs/heads/master
-rw-r--r--zuul/ansible/callback/zuul_json.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/zuul/ansible/callback/zuul_json.py b/zuul/ansible/callback/zuul_json.py
index 2b574b6..bbd2c24 100644
--- a/zuul/ansible/callback/zuul_json.py
+++ b/zuul/ansible/callback/zuul_json.py
@@ -55,7 +55,6 @@ class CallbackModule(CallbackBase):
55 def __init__(self, display=None): 55 def __init__(self, display=None):
56 super(CallbackModule, self).__init__(display) 56 super(CallbackModule, self).__init__(display)
57 self.results = [] 57 self.results = []
58 self.output = []
59 self.playbook = {} 58 self.playbook = {}
60 logging_config = logconfig.load_job_config( 59 logging_config = logconfig.load_job_config(
61 os.environ['ZUUL_JOB_LOG_CONFIG']) 60 os.environ['ZUUL_JOB_LOG_CONFIG'])
@@ -63,11 +62,6 @@ class CallbackModule(CallbackBase):
63 self.output_path = os.path.splitext( 62 self.output_path = os.path.splitext(
64 logging_config.job_output_file)[0] + '.json' 63 logging_config.job_output_file)[0] + '.json'
65 64
66 # For now, just read in the old file and write it all out again
67 # This may well not scale from a memory perspective- but let's see how
68 # it goes.
69 if os.path.exists(self.output_path):
70 self.output = json.load(open(self.output_path, 'r'))
71 self._playbook_name = None 65 self._playbook_name = None
72 66
73 def _new_playbook(self, play): 67 def _new_playbook(self, play):
@@ -173,9 +167,16 @@ class CallbackModule(CallbackBase):
173 167
174 self.playbook['plays'] = self.results 168 self.playbook['plays'] = self.results
175 self.playbook['stats'] = summary 169 self.playbook['stats'] = summary
176 self.output.append(self.playbook)
177 170
178 json.dump(self.output, open(self.output_path, 'w'), 171 # For now, just read in the old file and write it all out again
172 # This may well not scale from a memory perspective- but let's see how
173 # it goes.
174 output = []
175 if os.path.exists(self.output_path):
176 output = json.load(open(self.output_path, 'r'))
177 output.append(self.playbook)
178
179 json.dump(output, open(self.output_path, 'w'),
179 indent=4, sort_keys=True, separators=(',', ': ')) 180 indent=4, sort_keys=True, separators=(',', ': '))
180 181
181 v2_runner_on_failed = v2_runner_on_ok 182 v2_runner_on_failed = v2_runner_on_ok