소스 검색

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

Dmitry Sen 11 년 전
부모
커밋
5ba4a2470e
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  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)