ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlun...@apache.org
Subject ambari git commit: AMBARI-15678: YARN service_check doesn't fail when application status is not reasonable (Masahiro Tanaka via jluniya)
Date Fri, 22 Apr 2016 20:35:42 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 5fc461804 -> 108a1209b


AMBARI-15678: YARN service_check doesn't fail when application status is not reasonable (Masahiro
Tanaka via jluniya)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/108a1209
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/108a1209
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/108a1209

Branch: refs/heads/trunk
Commit: 108a1209b4724f365bc53da55919d544dcff70bd
Parents: 5fc4618
Author: Jayush Luniya <jluniya@hortonworks.com>
Authored: Fri Apr 22 13:35:35 2016 -0700
Committer: Jayush Luniya <jluniya@hortonworks.com>
Committed: Fri Apr 22 13:35:35 2016 -0700

----------------------------------------------------------------------
 .../2.1.0.2.0/package/scripts/service_check.py     | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/108a1209/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service_check.py
b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service_check.py
index e8d98ab..792a681 100644
--- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service_check.py
+++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service_check.py
@@ -116,7 +116,6 @@ class ServiceCheckDefault(ServiceCheck):
       if "application" in item:
         application_name = item
 
-    json_response_received = False
     for rm_webapp_address in params.rm_webapp_addresses_list:
       info_app_url = params.scheme + "://" + rm_webapp_address + "/ws/v1/cluster/apps/" +
application_name
 
@@ -129,16 +128,16 @@ class ServiceCheckDefault(ServiceCheck):
 
       try:
         json_response = json.loads(stdout)
-
-        json_response_received = True
-
-        if json_response['app']['state'] != "FINISHED" or json_response['app']['finalStatus']
!= "SUCCEEDED":
-          raise Exception("Application " + app_url + " state/status is not valid. Should
be FINISHED/SUCCEEDED.")
       except Exception as e:
-        pass
+        raise Exception("Could not get json response from YARN API")
+      
+      if json_response is None or 'app' not in json_response or \
+              'state' not in json_response['app'] or 'finalStatus' not in json_response['app']:
+        raise Exception("Application " + app_url + " returns invalid data.")
+
+      if json_response['app']['state'] != "FINISHED" or json_response['app']['finalStatus']
!= "SUCCEEDED":
+        raise Exception("Application " + app_url + " state/status is not valid. Should be
FINISHED/SUCCEEDED.")
 
-    if not json_response_received:
-      raise Exception("Could not get json response from YARN API")
 
 
 if __name__ == "__main__":


Mime
View raw message