Pārlūkot izejas kodu

AMBARI-13034. If for some reason, structured-out-status.json is empty then ambari-server will fail to report any status.(vbrodetskyi)

Vitaly Brodetskyi 10 gadi atpakaļ
vecāks
revīzija
09633340e1

+ 10 - 9
ambari-common/src/main/python/resource_management/libraries/script/script.py

@@ -111,15 +111,16 @@ class Script(object):
   def load_structured_out(self):
     Script.structuredOut = {}
     if os.path.exists(self.stroutfile):
-      with open(self.stroutfile, 'r') as fp:
-        try:
-          Script.structuredOut = json.load(fp)
-        except Exception:
-          errMsg = 'Unable to read structured output from ' + self.stroutfile
-          self.logger.warn(errMsg)
-          pass
-
-    # version is only set in a specific way and should not be carried 
+      if os.path.getsize(self.stroutfile) > 0:
+        with open(self.stroutfile, 'r') as fp:
+          try:
+            Script.structuredOut = json.load(fp)
+          except Exception:
+            errMsg = 'Unable to read structured output from ' + self.stroutfile
+            self.logger.warn(errMsg)
+            pass
+
+    # version is only set in a specific way and should not be carried
     if "version" in Script.structuredOut:
       del Script.structuredOut["version"]
     # reset security issues and errors found on previous runs