summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-12-06 21:55:58 +0000
committerGerrit Code Review <review@openstack.org>2018-12-06 21:55:58 +0000
commite2520b93c34bcb0e8e7e7765f2b9bfc0d263e52a (patch)
tree84e2752dc42e977821067d458348d6e081ac0025
parent1c6b48b98d6701e6705d0504f54b6e6ecf6f5e63 (diff)
parent43a03ef19f191a59370537858add32989ca19a89 (diff)
Merge "Read old json data right before writing new data"
-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