Commit 775860e6 authored by Alain Takoudjou's avatar Alain Takoudjou

monitor: run promise script should not fail when json is bad

parent c8aa019e
......@@ -137,7 +137,7 @@ md5sum = 280412f9024030c8cae343c2b07e5130
recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/scripts/run-promise.py
rendered = ${buildout:parts-directory}/monitor-scripts/run-promise.py
md5sum = 2570b11cd1f718f240a9c7a05ffa861d
md5sum = 641c6917bbd19a7abaebb120ccd4e713
mode = 0755
context =
raw python ${buildout:directory}/bin/${extra-eggs:interpreter}
......
......@@ -10,6 +10,7 @@ import time
from shutil import copyfile
import glob
import argparse
import traceback
def parseArguments():
"""
......@@ -71,9 +72,12 @@ def main():
status_json['change-time'] = ps_process.create_time()
if os.path.exists(parser.output):
with open(parser.output) as f:
try:
last_result = json.loads(f.read())
if status_json['status'] == last_result['status'] and last_result.has_key('change-time'):
status_json['change-time'] = last_result['change-time']
except ValueError:
pass
updateStatusHistoryFolder(
parser.promise_name,
......@@ -99,7 +103,11 @@ def updateStatusHistoryFolder(name, status_file, history_folder, promise_type):
pass
else: raise
with open(status_file, 'r') as sf:
try:
status_dict = json.loads(sf.read())
except ValueError:
traceback.print_exc()
return
if promise_type == 'status':
filename = '%s.history.json' % name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment