Browse Source

AMBARI-4103 Structured command output may contain exception data in some cases (+CommandStatusDict) (dsen)

Dmitry Sen 11 years ago
parent
commit
5ba4a2470e
1 changed files with 5 additions and 3 deletions
  1. 5 3
      ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py

+ 5 - 3
ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py

@@ -97,13 +97,15 @@ class CommandStatusDict():
     try:
       tmpout = open(report['tmpout'], 'r').read()
       tmperr = open(report['tmperr'], 'r').read()
-      with open(report['structuredOut'], 'r') as fp:
-        tmpstructuredout = json.load(fp)
     except Exception, err:
       logger.warn(err)
       tmpout = '...'
       tmperr = '...'
-      tmpstructuredout = ''
+    try:
+      with open(report['structuredOut'], 'r') as fp:
+        tmpstructuredout = json.load(fp)
+    except Exception:
+      tmpstructuredout = {}
     grep = Grep()
     output = grep.tail(tmpout, Grep.OUTPUT_LAST_LINES)
     inprogress = self.generate_report_template(command)