Browse Source

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

Dmitry Sen 11 năm trước cách đây
mục cha
commit
5ba4a2470e

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

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