ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject ambari git commit: AMBARI-15650. Output short logs summary on start/stop failure (aonishuk)
Date Thu, 31 Mar 2016 15:45:35 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 7a909ade9 -> 017fbf130


AMBARI-15650. Output short logs summary on start/stop failure (aonishuk)


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

Branch: refs/heads/trunk
Commit: 017fbf130f7a3ce880baa11bf6a783f3ca850d78
Parents: 7a909ad
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Thu Mar 31 18:45:27 2016 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Thu Mar 31 18:45:27 2016 +0300

----------------------------------------------------------------------
 .../libraries/functions/__init__.py             |  1 +
 .../libraries/functions/show_logs.py            | 39 +++++++++++++++
 .../libraries/functions/version_select_util.py  |  2 +-
 .../package/scripts/accumulo_service.py         | 13 +++--
 .../0.1.0/package/scripts/ams_service.py        | 22 ++++++---
 .../package/scripts/metadata_server.py          | 30 ++++++++----
 .../FALCON/0.5.0.2.1/package/scripts/falcon.py  | 27 +++++++----
 .../FLUME/1.4.0.2.0/package/scripts/flume.py    | 15 ++++--
 .../0.96.0.2.0/package/scripts/hbase_service.py | 31 +++++++-----
 .../2.1.0.2.0/package/scripts/params_linux.py   |  3 +-
 .../HDFS/2.1.0.2.0/package/scripts/utils.py     | 14 +++++-
 .../0.12.0.2.0/package/scripts/hive_service.py  | 22 ++++++---
 .../package/scripts/webhcat_service.py          | 36 +++++++++-----
 .../0.8.1.2.2/package/scripts/kafka_broker.py   | 23 ++++++---
 .../0.5.0.2.2/package/scripts/knox_gateway.py   | 28 +++++++----
 .../4.0.0.2.0/package/scripts/oozie_service.py  | 21 +++++---
 .../0.4.0/package/scripts/ranger_service.py     | 20 +++++---
 .../0.5.0.2.3/package/scripts/kms_service.py    | 13 ++++-
 .../1.2.0.2.2/package/scripts/spark_service.py  | 51 +++++++++++++-------
 .../STORM/0.9.1.2.1/package/scripts/service.py  | 17 ++++---
 .../YARN/2.1.0.2.0/package/scripts/service.py   | 31 ++++++++----
 .../package/scripts/zookeeper_service.py        | 29 +++++++----
 .../2.0.6/ZOOKEEPER/test_zookeeper_server.py    |  8 ++-
 .../stacks/2.3/ATLAS/test_metadata_server.py    |  3 +-
 24 files changed, 358 insertions(+), 141 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py b/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py
index e886fe4..ff4fddf 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py
@@ -43,6 +43,7 @@ from resource_management.libraries.functions.get_lzo_packages import *
 from resource_management.libraries.functions.setup_ranger_plugin import *
 from resource_management.libraries.functions.curl_krb_request import *
 from resource_management.libraries.functions.get_bare_principal import *
+from resource_management.libraries.functions.show_logs import *
 IS_WINDOWS = platform.system() == "Windows"
 
 if IS_WINDOWS:

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-common/src/main/python/resource_management/libraries/functions/show_logs.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/show_logs.py b/ambari-common/src/main/python/resource_management/libraries/functions/show_logs.py
new file mode 100644
index 0000000..bb2e12c
--- /dev/null
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/show_logs.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+__all__ = ["show_logs"]
+
+from resource_management.core.resources.system import Execute
+from resource_management.libraries.functions.format import format
+
+LAST_LINES_OUTPUT_COUNT = 40
+
+def show_logs(log_dir, user):
+  """
+  This should be used in 'except' block of start or stop Execute of services or of command which checks if start was fine.
+  It allows to give additional debugging information without need to have access to log files.
+  
+  Don't forget to call "raise" after using the function or else the original exception will be masked.
+  """
+  lines_count = LAST_LINES_OUTPUT_COUNT
+  Execute(format("log_files=`find {log_dir} -maxdepth 1 -type f` ; [ ! -z \"$log_files\" ] && tail -n {lines_count} $log_files"),
+          logoutput = True,
+          ignore_failures = True, # if this fails should not overwrite the actual exception
+          user = user, # need to have permissions to read log files
+  )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py b/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
index 05e6eb6..9122a0e 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
@@ -55,7 +55,7 @@ def get_component_version(stack_name, component_name):
       # This is necessary because Ubuntu returns "stdin: is not a tty", see AMBARI-8088
       with open(tmpfile.name, 'r') as file:
         get_stack_comp_version_cmd = '%s status %s > %s' % (stack_selector_path, component_name, tmpfile.name)
-        code, stdoutdata = shell.call(get_stack_comp_version_cmd)
+        code, stdoutdata = shell.call(get_stack_comp_version_cmd, quiet=True)
         out = file.read()
 
       if code != 0 or out is None:

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/ACCUMULO/1.6.1.2.2.0/package/scripts/accumulo_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/ACCUMULO/1.6.1.2.2.0/package/scripts/accumulo_service.py b/ambari-server/src/main/resources/common-services/ACCUMULO/1.6.1.2.2.0/package/scripts/accumulo_service.py
index e71d5af..33d3273 100644
--- a/ambari-server/src/main/resources/common-services/ACCUMULO/1.6.1.2.2.0/package/scripts/accumulo_service.py
+++ b/ambari-server/src/main/resources/common-services/ACCUMULO/1.6.1.2.2.0/package/scripts/accumulo_service.py
@@ -19,6 +19,7 @@ limitations under the License.
 """
 
 from resource_management import *
+from resource_management.libraries.functions.show_logs import show_logs
 import time
 import os
 
@@ -48,10 +49,14 @@ def accumulo_service( name,
       if name == 'monitor' and params.accumulo_monitor_bind_all:
         address = '0.0.0.0'
       daemon_cmd = format("{daemon_script} {role} --address {address} > {log_dir}/accumulo-{role}.out 2>{log_dir}/accumulo-{role}.err & echo $! > {pid_file}")
-      Execute ( daemon_cmd,
-        not_if=as_user(pid_exists, params.accumulo_user),
-        user=params.accumulo_user
-      )
+      try:
+        Execute ( daemon_cmd,
+          not_if=as_user(pid_exists, params.accumulo_user),
+          user=params.accumulo_user
+        )
+      except:
+        show_logs(params.log_dir, params.accumulo_user)
+        raise
 
     elif action == 'stop':
       no_pid_exists = format("! ({pid_exists})")

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/ams_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/ams_service.py b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/ams_service.py
index c9188c2..eb1b6d7 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/ams_service.py
+++ b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/ams_service.py
@@ -19,6 +19,7 @@ limitations under the License.
 """
 
 from resource_management import *
+from resource_management.libraries.functions.show_logs import show_logs
 from ambari_commons import OSConst
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from hbase_service import hbase_service
@@ -77,9 +78,13 @@ def ams_service(name, action):
       else:
         daemon_cmd = format("{cmd} start")
 
-      Execute(daemon_cmd,
-              user=params.ams_user
-      )
+      try:
+        Execute(daemon_cmd,
+                user=params.ams_user
+        )
+      except:
+        show_logs(params.ams_collector_log_dir, params.ams_user)
+        raise
 
       pass
     elif action == 'stop':
@@ -97,9 +102,14 @@ def ams_service(name, action):
 
     if action == 'start':
       daemon_cmd = format("{cmd} start")
-      Execute(daemon_cmd,
-              user=params.ams_user
-      )
+      
+      try:
+        Execute(daemon_cmd,
+                user=params.ams_user
+        )
+      except:
+        show_logs(params.ams_monitor_log_dir, params.ams_user)
+        raise      
 
       pass
     elif action == 'stop':

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/package/scripts/metadata_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/package/scripts/metadata_server.py b/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/package/scripts/metadata_server.py
index b6374f9..46c8fd3 100644
--- a/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/package/scripts/metadata_server.py
+++ b/ambari-server/src/main/resources/common-services/ATLAS/0.1.0.2.3/package/scripts/metadata_server.py
@@ -19,12 +19,13 @@ limitations under the License.
 from metadata import metadata
 from resource_management.libraries.functions import conf_select
 from resource_management.libraries.functions import stack_select
-from resource_management import Execute, check_process_status, Script
+from resource_management import Execute, File, check_process_status, Script
 from resource_management.libraries.functions import format
 from resource_management.libraries.functions.version import compare_versions, format_stack_version
 from resource_management.libraries.functions.security_commons import build_expectations, \
   get_params_from_filesystem, validate_security_config_properties, \
   FILE_TYPE_PROPERTIES
+from resource_management.libraries.functions.show_logs import show_logs
 
 class MetadataServer(Script):
 
@@ -54,19 +55,30 @@ class MetadataServer(Script):
 
     daemon_cmd = format('source {params.conf_dir}/atlas-env.sh ; {params.metadata_start_script}')
     no_op_test = format('ls {params.pid_file} >/dev/null 2>&1 && ps -p `cat {params.pid_file}` >/dev/null 2>&1')
-    Execute(daemon_cmd,
-            user=params.metadata_user,
-            not_if=no_op_test
-    )
+    
+    try:
+      Execute(daemon_cmd,
+              user=params.metadata_user,
+              not_if=no_op_test
+      )
+    except:
+      show_logs(params.log_dir, params.metadata_user)
+      raise
 
   def stop(self, env, upgrade_type=None):
     import params
     env.set_params(params)
     daemon_cmd = format('source {params.conf_dir}/atlas-env.sh; {params.metadata_stop_script}')
-    Execute(daemon_cmd,
-            user=params.metadata_user,
-    )
-    Execute (format("rm -f {params.pid_file}"))
+    
+    try:
+      Execute(daemon_cmd,
+              user=params.metadata_user,
+      )
+    except:
+      show_logs(params.log_dir, params.metadata_user)
+      raise
+    
+    File(params.pid_file, action="delete")
 
   def status(self, env):
     import status_params

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py b/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
index 7b469d3..46457ad 100644
--- a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
+++ b/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
@@ -31,6 +31,7 @@ from resource_management.core.resources.system import Link
 from resource_management.libraries.script import Script
 from resource_management.libraries.resources import PropertiesFile
 from resource_management.libraries.functions import format
+from resource_management.libraries.functions.show_logs import show_logs
 
 from ambari_commons import OSConst
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
@@ -179,10 +180,14 @@ def falcon(type, action = None, upgrade_type=None):
     environment_dictionary = { "HADOOP_HOME" : params.hadoop_home_dir }
 
     if action == 'start':
-      Execute(format('{falcon_home}/bin/falcon-start -port {falcon_port}'),
-        user = params.falcon_user,
-        path = params.hadoop_bin_dir,
-        environment=environment_dictionary)
+      try:
+        Execute(format('{falcon_home}/bin/falcon-start -port {falcon_port}'),
+          user = params.falcon_user,
+          path = params.hadoop_bin_dir,
+          environment=environment_dictionary)
+      except:
+        show_logs(params.falcon_log_dir, params.falcon_user)
+        raise
 
       if params.has_atlas:
         atlas_falcon_hook_dir = os.path.join(params.atlas_home_dir, "hook", "falcon")
@@ -195,11 +200,15 @@ def falcon(type, action = None, upgrade_type=None):
               Link(falcon_lib_file_name, to = atlas_falcon_hook_file_name)
 
     if action == 'stop':
-      Execute(format('{falcon_home}/bin/falcon-stop'),
-        user = params.falcon_user,
-        path = params.hadoop_bin_dir,
-        environment=environment_dictionary)
-
+      try:
+        Execute(format('{falcon_home}/bin/falcon-stop'),
+          user = params.falcon_user,
+          path = params.hadoop_bin_dir,
+          environment=environment_dictionary)
+      except:
+        show_logs(params.falcon_log_dir, params.falcon_user)
+        raise
+      
       File(params.server_pid_file, action = 'delete')
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/flume.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/flume.py b/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/flume.py
index b30b122..db52431 100644
--- a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/flume.py
+++ b/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/flume.py
@@ -26,6 +26,7 @@ from resource_management.libraries.functions.flume_agent_helper import find_expe
 from resource_management.libraries.functions.flume_agent_helper import await_flume_process_termination
 from ambari_commons import OSConst
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
+from resource_management.libraries.functions.show_logs import show_logs
 
 @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
 def flume(action = None):
@@ -184,10 +185,15 @@ def flume(action = None):
         # sometimes startup spawns a couple of threads - so only the first line may count
         pid_cmd = as_sudo(('pgrep', '-o', '-u', params.flume_user, '-f', format('^{java_home}.*{agent}.*'))) + \
         " | " + as_sudo(('tee', flume_agent_pid_file)) + "  && test ${PIPESTATUS[0]} -eq 0"
-        Execute(pid_cmd,
-                logoutput=True,
-                tries=20,
-                try_sleep=10)
+        
+        try:
+          Execute(pid_cmd,
+                  logoutput=True,
+                  tries=20,
+                  try_sleep=10)
+        except:
+          show_logs(params.flume_log_dir, None)
+          raise
 
     pass
   elif action == 'stop':
@@ -211,6 +217,7 @@ def flume(action = None):
         Execute(("kill", "-15", pid), sudo=True)    # kill command has to be a tuple
       
       if not await_flume_process_termination(pid_file):
+        show_logs(params.flume_log_dir, None)
         raise Fail("Can't stop flume agent: {0}".format(agent))
         
       File(pid_file, action = 'delete')

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_service.py b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_service.py
index ef4cd5b..a6904f6 100644
--- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_service.py
+++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_service.py
@@ -35,20 +35,29 @@ def hbase_service(
     if action == 'start':
       daemon_cmd = format("{cmd} start {role}")
       
-      Execute ( daemon_cmd,
-        not_if = no_op_test,
-        user = params.hbase_user
-      )
+      try:
+        Execute ( daemon_cmd,
+          not_if = no_op_test,
+          user = params.hbase_user
+        )
+      except:
+        show_logs(params.log_dir, params.hbase_user)
+        raise
     elif action == 'stop':
       daemon_cmd = format("{cmd} stop {role}")
 
-      Execute ( daemon_cmd,
-        user = params.hbase_user,
-        only_if = no_op_test,
-        # BUGFIX: hbase regionserver sometimes hangs when nn is in safemode
-        timeout = 30,
-        on_timeout = format("! ( {no_op_test} ) || {sudo} -H -E kill -9 `{pid_expression}`"),
-      )
+      try:
+        Execute ( daemon_cmd,
+          user = params.hbase_user,
+          only_if = no_op_test,
+          # BUGFIX: hbase regionserver sometimes hangs when nn is in safemode
+          timeout = 30,
+          on_timeout = format("! ( {no_op_test} ) || {sudo} -H -E kill -9 `{pid_expression}`"),
+        )
+      except:
+        show_logs(params.log_dir, params.hbase_user)
+        raise
+      
       File(pid_file,
            action = "delete",
       )

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params_linux.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params_linux.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params_linux.py
index d6dec26..d4894ba 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params_linux.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params_linux.py
@@ -223,7 +223,8 @@ jn_edits_dir = config['configurations']['hdfs-site']['dfs.journalnode.edits.dir'
 
 dfs_name_dir = config['configurations']['hdfs-site']['dfs.namenode.name.dir']
 
-namenode_dirs_created_stub_dir = format("{hdfs_log_dir_prefix}/{hdfs_user}")
+hdfs_log_dir = format("{hdfs_log_dir_prefix}/{hdfs_user}")
+namenode_dirs_created_stub_dir = hdfs_log_dir
 namenode_dirs_stub_filename = "namenode_dirs_created"
 
 smoke_hdfs_user_dir = format("/user/{smoke_user}")

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
index 339d52a..f9ee40d 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
@@ -34,6 +34,7 @@ from resource_management.libraries.functions.curl_krb_request import curl_krb_re
 from resource_management.core.exceptions import Fail
 from resource_management.libraries.functions.namenode_ha_utils import get_namenode_states
 from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions.show_logs import show_logs
 
 from zkfc_slave import ZkfcSlave
 
@@ -265,9 +266,18 @@ def service(action=None, name=None, user=None, options="", create_pid_dir=False,
   if action == "start":
     # remove pid file from dead process
     File(pid_file, action="delete", not_if=process_id_exists_command)
-    Execute(daemon_cmd, not_if=process_id_exists_command, environment=hadoop_env_exports)
+    
+    try:
+      Execute(daemon_cmd, not_if=process_id_exists_command, environment=hadoop_env_exports)
+    except:
+      show_logs(params.hdfs_log_dir, user)
+      raise
   elif action == "stop":
-    Execute(daemon_cmd, only_if=process_id_exists_command, environment=hadoop_env_exports)
+    try:
+      Execute(daemon_cmd, only_if=process_id_exists_command, environment=hadoop_env_exports)
+    except:
+      show_logs(params.hdfs_log_dir, user)
+      raise
     File(pid_file, action="delete")
 
 def get_jmx_data(nn_address, modeler_type, metric, encrypted=False, security_enabled=False):

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
index 2f94dfb..3aa6536 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
@@ -31,6 +31,7 @@ from resource_management.core.exceptions import Fail
 from resource_management.core.shell import as_user
 from resource_management.libraries.functions.hive_check import check_thrift_port_sasl
 from resource_management.libraries.functions import get_user_call_output
+from resource_management.libraries.functions.show_logs import show_logs
 
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons import OSConst
@@ -100,8 +101,13 @@ def hive_service(name, action='start', upgrade_type=None):
       db_connection_check_command = format(
         "{java64_home}/bin/java -cp {check_db_connection_jar}:{target} org.apache.ambari.server.DBConnectionVerification '{hive_jdbc_connection_url}' {hive_metastore_user_name} {hive_metastore_user_passwd!p} {hive_jdbc_driver}")
       
-      Execute(db_connection_check_command,
+      try:
+        Execute(db_connection_check_command,
               path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin', tries=5, try_sleep=10)
+      except:
+        show_logs(params.hive_log_dir, user)
+        raise
+        
   elif action == 'stop':
 
     daemon_kill_cmd = format("{sudo} kill {pid}")
@@ -116,11 +122,15 @@ def hive_service(name, action='start', upgrade_type=None):
       not_if = format("! ({process_id_exists_command}) || ( sleep {wait_time} && ! ({process_id_exists_command}) )")
     )
 
-    # check if stopped the process, else fail the task
-    Execute(format("! ({process_id_exists_command})"),
-      tries=20,
-      try_sleep=3,
-    )
+    try:
+      # check if stopped the process, else fail the task
+      Execute(format("! ({process_id_exists_command})"),
+        tries=20,
+        try_sleep=3,
+      )
+    except:
+      show_logs(params.hive_log_dir, user)
+      raise
 
     File(pid_file,
          action = "delete"

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat_service.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat_service.py
index 2553c70..10e0990 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat_service.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat_service.py
@@ -46,15 +46,23 @@ def webhcat_service(action='start', upgrade_type=None):
 
     daemon_cmd = format('cd {hcat_pid_dir} ; {cmd} start')
     no_op_test = as_user(format('ls {webhcat_pid_file} >/dev/null 2>&1 && ps -p `cat {webhcat_pid_file}` >/dev/null 2>&1'), user=params.webhcat_user)
-    Execute(daemon_cmd,
-            user=params.webhcat_user,
-            not_if=no_op_test,
-            environment = environ)
+    try:
+      Execute(daemon_cmd,
+              user=params.webhcat_user,
+              not_if=no_op_test,
+              environment = environ)
+    except:
+      show_logs(params.hcat_log_dir, params.webhcat_user)
+      raise
   elif action == 'stop':
     daemon_cmd = format('{cmd} stop')
-    Execute(daemon_cmd,
-            user = params.webhcat_user,
-            environment = environ)
+    try:
+      Execute(daemon_cmd,
+              user = params.webhcat_user,
+              environment = environ)
+    except:
+      show_logs(params.hcat_log_dir, params.webhcat_user)
+      raise
 
     pid_expression = "`" + as_user(format("cat {webhcat_pid_file}"), user=params.webhcat_user) + "`"
     process_id_exists_command = format("ls {webhcat_pid_file} >/dev/null 2>&1 && ps -p {pid_expression} >/dev/null 2>&1")
@@ -64,11 +72,15 @@ def webhcat_service(action='start', upgrade_type=None):
             not_if = format("! ({process_id_exists_command}) || ( sleep {wait_time} && ! ({process_id_exists_command}) )")
     )
 
-    # check if stopped the process, else fail the task
-    Execute(format("! ({process_id_exists_command})"),
-            tries=20,
-            try_sleep=3,
-    )
+    try:
+      # check if stopped the process, else fail the task
+      Execute(format("! ({process_id_exists_command})"),
+              tries=20,
+              try_sleep=3,
+      )
+    except:
+      show_logs(params.hcat_log_dir, params.webhcat_user)
+      raise
 
     File(params.webhcat_pid_file,
          action="delete",

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/KAFKA/0.8.1.2.2/package/scripts/kafka_broker.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KAFKA/0.8.1.2.2/package/scripts/kafka_broker.py b/ambari-server/src/main/resources/common-services/KAFKA/0.8.1.2.2/package/scripts/kafka_broker.py
index 2043cfa..41074db 100644
--- a/ambari-server/src/main/resources/common-services/KAFKA/0.8.1.2.2/package/scripts/kafka_broker.py
+++ b/ambari-server/src/main/resources/common-services/KAFKA/0.8.1.2.2/package/scripts/kafka_broker.py
@@ -27,6 +27,7 @@ from resource_management.libraries.functions.format import format
 from resource_management.libraries.functions.check_process_status import check_process_status
 from resource_management.libraries.functions import StackFeature
 from resource_management.libraries.functions.stack_features import check_stack_feature
+from resource_management.libraries.functions.show_logs import show_logs
 from kafka import ensure_base_directories
 
 import upgrade
@@ -82,10 +83,14 @@ class KafkaBroker(Script):
       setup_ranger_kafka() #Ranger Kafka Plugin related call 
     daemon_cmd = format('source {params.conf_dir}/kafka-env.sh ; {params.kafka_bin} start')
     no_op_test = format('ls {params.kafka_pid_file} >/dev/null 2>&1 && ps -p `cat {params.kafka_pid_file}` >/dev/null 2>&1')
-    Execute(daemon_cmd,
-            user=params.kafka_user,
-            not_if=no_op_test
-    )
+    try:
+      Execute(daemon_cmd,
+              user=params.kafka_user,
+              not_if=no_op_test
+      )
+    except:
+      show_logs(params.kafka_log_dir, params.kafka_user)
+      raise
 
   def stop(self, env, upgrade_type=None):
     import params
@@ -95,9 +100,13 @@ class KafkaBroker(Script):
     # before attempting to stop Kafka Broker
     ensure_base_directories()
     daemon_cmd = format('source {params.conf_dir}/kafka-env.sh; {params.kafka_bin} stop')
-    Execute(daemon_cmd,
-            user=params.kafka_user,
-    )
+    try:
+      Execute(daemon_cmd,
+              user=params.kafka_user,
+      )
+    except:
+      show_logs(params.kafka_log_dir, params.kafka_user)
+      raise
     File(params.kafka_pid_file,
           action = "delete"
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py
index af0442c..b72fc6f 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py
@@ -35,6 +35,7 @@ from resource_management.libraries.functions.security_commons import build_expec
 from resource_management.core.resources.system import File, Execute, Directory, Link
 from resource_management.core.resources.service import Service
 from resource_management.core.logger import Logger
+from resource_management.libraries.functions.show_logs import show_logs
 
 from ambari_commons import OSConst, OSCheck
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
@@ -157,11 +158,15 @@ class KnoxGatewayDefault(KnoxGateway):
 
     update_knox_logfolder_permissions()
 
-    Execute(daemon_cmd,
-            user=params.knox_user,
-            environment={'JAVA_HOME': params.java_home},
-            not_if=no_op_test
-    )
+    try:
+      Execute(daemon_cmd,
+              user=params.knox_user,
+              environment={'JAVA_HOME': params.java_home},
+              not_if=no_op_test
+      )
+    except:
+      show_logs(params.knox_logs_dir, params.knox_user)
+      raise
 
   def stop(self, env, upgrade_type=None):
     import params
@@ -170,10 +175,15 @@ class KnoxGatewayDefault(KnoxGateway):
 
     update_knox_logfolder_permissions()
 
-    Execute(daemon_cmd,
-            environment={'JAVA_HOME': params.java_home},
-            user=params.knox_user,
-    )
+    try:
+      Execute(daemon_cmd,
+              environment={'JAVA_HOME': params.java_home},
+              user=params.knox_user,
+      )
+    except:
+      show_logs(params.knox_logs_dir, params.knox_user)
+      raise
+    
     File(params.knox_pid_file,
          action="delete",
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
index 5a2474f..3060353 100644
--- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
+++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
@@ -20,6 +20,7 @@ limitations under the License.
 import os
 from resource_management import *
 from resource_management.core.shell import as_user
+from resource_management.libraries.functions.show_logs import show_logs
 from resource_management.libraries.providers.hdfs_resource import WebHDFSUtil
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons import OSConst
@@ -124,15 +125,23 @@ def oozie_service(action = 'start', upgrade_type=None):
         params.HdfsResource(None, action="execute")
         
 
-    # start oozie
-    Execute( start_cmd, environment=environment, user = params.oozie_user,
-      not_if = no_op_test )
+    try:
+      # start oozie
+      Execute( start_cmd, environment=environment, user = params.oozie_user,
+        not_if = no_op_test )
+    except:
+      show_logs(params.oozie_log_dir, params.oozie_user)
+      raise
 
   elif action == 'stop':
     stop_cmd  = format("cd {oozie_tmp_dir} && {oozie_home}/bin/oozie-stop.sh")
 
-    # stop oozie
-    Execute(stop_cmd, environment=environment, only_if  = no_op_test,
-      user = params.oozie_user)
+    try:
+      # stop oozie
+      Execute(stop_cmd, environment=environment, only_if  = no_op_test,
+        user = params.oozie_user)
+    except:
+      show_logs(params.oozie_log_dir, params.oozie_user)
+      raise
 
     File(params.pid_file, action = "delete")

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_service.py b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_service.py
index 0cb56aa..9477b8e 100644
--- a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_service.py
+++ b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_service.py
@@ -28,17 +28,25 @@ def ranger_service(name, action=None):
   
   if name == 'ranger_admin':
     no_op_test = format('ps -ef | grep proc_rangeradmin | grep -v grep')
-    Execute(params.ranger_start, environment=env_dict, user=params.unix_user, not_if=no_op_test)
+    try:
+      Execute(params.ranger_start, environment=env_dict, user=params.unix_user, not_if=no_op_test)
+    except:
+      show_logs(params.admin_log_dir, params.unix_user)
+      raise
   elif name == 'ranger_usersync':
     no_op_test = format('ps -ef | grep proc_rangerusersync | grep -v grep')
 
 
     if params.stack_supports_usersync_non_root:
-      Execute(params.usersync_start,
-              environment=env_dict,
-              not_if=no_op_test,
-              user=params.unix_user,
-      )
+      try:
+        Execute(params.usersync_start,
+                environment=env_dict,
+                not_if=no_op_test,
+                user=params.unix_user,
+        )
+      except:
+        show_logs(params.usersync_log_dir, params.unix_user)
+        raise
     else:
       # Usersync requires to be run as root for 2.2
       Execute((params.usersync_start,),

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms_service.py b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms_service.py
index f5b0c83..55c0486 100644
--- a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms_service.py
+++ b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms_service.py
@@ -23,6 +23,7 @@ from resource_management.core import shell
 from resource_management.libraries.functions.format import format
 from resource_management.core.exceptions import ComponentIsNotRunning
 from resource_management.core.logger import Logger
+from resource_management.libraries.functions.show_logs import show_logs
 
 def kms_service(action='start'):
   import params
@@ -34,7 +35,15 @@ def kms_service(action='start'):
   if action == 'start':
     no_op_test = format('ps -ef | grep proc_rangerkms | grep -v grep')
     cmd = format('{kms_home}/ranger-kms start')
-    Execute(cmd, not_if=no_op_test, environment=env_dict, user=format('{kms_user}'))
+    try:
+      Execute(cmd, not_if=no_op_test, environment=env_dict, user=format('{kms_user}'))
+    except:
+      show_logs(params.kms_log_dir, params.kms_user)
+      raise
   elif action == 'stop':
     cmd = format('{kms_home}/ranger-kms stop')
-    Execute(cmd, environment=env_dict, user=format('{kms_user}'))
+    try:
+      Execute(cmd, environment=env_dict, user=format('{kms_user}'))
+    except:
+      show_logs(params.kms_log_dir, params.kms_user)
+      raise

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/SPARK/1.2.0.2.2/package/scripts/spark_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/SPARK/1.2.0.2.2/package/scripts/spark_service.py b/ambari-server/src/main/resources/common-services/SPARK/1.2.0.2.2/package/scripts/spark_service.py
index 6ada1c2..c3784d6 100644
--- a/ambari-server/src/main/resources/common-services/SPARK/1.2.0.2.2/package/scripts/spark_service.py
+++ b/ambari-server/src/main/resources/common-services/SPARK/1.2.0.2.2/package/scripts/spark_service.py
@@ -27,6 +27,7 @@ from resource_management.core.resources.system import File, Execute
 from resource_management.libraries.functions.version import format_stack_version
 from resource_management.libraries.functions.stack_features import check_stack_feature
 from resource_management.libraries.functions import StackFeature
+from resource_management.libraries.functions.show_logs import show_logs
 
 def spark_service(name, upgrade_type=None, action=None):
   import params
@@ -65,10 +66,14 @@ def spark_service(name, upgrade_type=None, action=None):
     if name == 'jobhistoryserver':
       historyserver_no_op_test = format(
       'ls {spark_history_server_pid_file} >/dev/null 2>&1 && ps -p `cat {spark_history_server_pid_file}` >/dev/null 2>&1')
-      Execute(format('{spark_history_server_start}'),
-              user=params.spark_user,
-              environment={'JAVA_HOME': params.java_home},
-              not_if=historyserver_no_op_test)
+      try:
+        Execute(format('{spark_history_server_start}'),
+                user=params.spark_user,
+                environment={'JAVA_HOME': params.java_home},
+                not_if=historyserver_no_op_test)
+      except:
+        show_logs(params.spark_log_dir, user=params.spark_user)
+        raise
 
     elif name == 'sparkthriftserver':
       if params.security_enabled:
@@ -78,26 +83,38 @@ def spark_service(name, upgrade_type=None, action=None):
 
       thriftserver_no_op_test = format(
       'ls {spark_thrift_server_pid_file} >/dev/null 2>&1 && ps -p `cat {spark_thrift_server_pid_file}` >/dev/null 2>&1')
-      Execute(format('{spark_thrift_server_start} --properties-file {spark_thrift_server_conf_file} {spark_thrift_cmd_opts_properties}'),
-              user=params.hive_user,
-              environment={'JAVA_HOME': params.java_home},
-              not_if=thriftserver_no_op_test
-      )
+      try:
+        Execute(format('{spark_thrift_server_start} --properties-file {spark_thrift_server_conf_file} {spark_thrift_cmd_opts_properties}'),
+                user=params.hive_user,
+                environment={'JAVA_HOME': params.java_home},
+                not_if=thriftserver_no_op_test
+        )
+      except:
+        show_logs(params.spark_log_dir, user=params.hive_user)
+        raise
   elif action == 'stop':
     if name == 'jobhistoryserver':
-      Execute(format('{spark_history_server_stop}'),
-              user=params.spark_user,
-              environment={'JAVA_HOME': params.java_home}
-      )
+      try:
+        Execute(format('{spark_history_server_stop}'),
+                user=params.spark_user,
+                environment={'JAVA_HOME': params.java_home}
+        )
+      except:
+        show_logs(params.spark_log_dir, user=params.spark_user)
+        raise
       File(params.spark_history_server_pid_file,
         action="delete"
       )
 
     elif name == 'sparkthriftserver':
-      Execute(format('{spark_thrift_server_stop}'),
-              user=params.hive_user,
-              environment={'JAVA_HOME': params.java_home}
-      )
+      try:
+        Execute(format('{spark_thrift_server_stop}'),
+                user=params.hive_user,
+                environment={'JAVA_HOME': params.java_home}
+        )
+      except:
+        show_logs(params.spark_log_dir, user=params.hive_user)
+        raise
       File(params.spark_thrift_server_pid_file,
         action="delete"
       )

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py
index 0222d71..d0b717f 100644
--- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py
+++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py
@@ -25,6 +25,7 @@ from resource_management.core.resources import File
 from resource_management.core.shell import as_user
 from resource_management.libraries.functions.format import format
 from resource_management.libraries.functions import get_user_call_output
+from resource_management.libraries.functions.show_logs import show_logs
 import time
 
 
@@ -65,12 +66,16 @@ def service(name, action = 'start'):
       wait_for_finish = False,
       path = params.storm_bin_dir)
 
-    Execute(crt_pid_cmd,
-      user = params.storm_user,
-      logoutput = True,
-      tries = tries_count,
-      try_sleep = 10,
-      path = params.storm_bin_dir)
+    try:
+      Execute(crt_pid_cmd,
+        user = params.storm_user,
+        logoutput = True,
+        tries = tries_count,
+        try_sleep = 10,
+        path = params.storm_bin_dir)
+    except:
+      show_logs(params.log_dir, params.storm_user)
+      raise
 
   elif action == "stop":
     process_dont_exist = format("! ({no_op_test})")

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
index 6d9aef5..0703c1f 100644
--- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
+++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
@@ -23,6 +23,7 @@ from resource_management import *
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons import OSConst
 from resource_management.core.shell import as_user
+from resource_management.libraries.functions.show_logs import show_logs
 
 @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
 def service(componentName, action='start', serviceName='yarn'):
@@ -44,6 +45,7 @@ def service(componentName, action='start', serviceName='yarn'):
     daemon = format("{mapred_bin}/mr-jobhistory-daemon.sh")
     pid_file = format("{mapred_pid_dir}/mapred-{mapred_user}-{componentName}.pid")
     usr = params.mapred_user
+    log_dir = params.yarn_log_dir
   else:
     # !!! yarn-daemon.sh deletes the PID for us; if we remove it the script
     # may not work correctly when stopping the service
@@ -51,6 +53,7 @@ def service(componentName, action='start', serviceName='yarn'):
     daemon = format("{yarn_bin}/yarn-daemon.sh")
     pid_file = format("{yarn_pid_dir}/yarn-{yarn_user}-{componentName}.pid")
     usr = params.yarn_user
+    log_dir = params.mapred_log_dir
 
   cmd = format("export HADOOP_LIBEXEC_DIR={hadoop_libexec_dir} && {daemon} --config {hadoop_conf_dir}")
 
@@ -69,19 +72,27 @@ def service(componentName, action='start', serviceName='yarn'):
          ignore_failures = True
       )
 
-    # Attempt to start the process. Internally, this is skipped if the process is already running.
-    Execute(daemon_cmd, user = usr, not_if = check_process)
-
-    # Ensure that the process with the expected PID exists.
-    Execute(check_process,
-            not_if = check_process,
-            tries=5,
-            try_sleep=1,
-    )
+    try:
+      # Attempt to start the process. Internally, this is skipped if the process is already running.
+      Execute(daemon_cmd, user = usr, not_if = check_process)
+  
+      # Ensure that the process with the expected PID exists.
+      Execute(check_process,
+              not_if = check_process,
+              tries=5,
+              try_sleep=1,
+      )
+    except:
+      show_logs(log_dir, usr)
+      raise
 
   elif action == 'stop':
     daemon_cmd = format("{cmd} stop {componentName}")
-    Execute(daemon_cmd, user=usr)
+    try:
+      Execute(daemon_cmd, user=usr)
+    except:
+      show_logs(log_dir, usr)
+      raise
 
     # !!! yarn-daemon doesn't need us to delete PIDs
     if delete_pid_file is True:

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper_service.py b/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper_service.py
index d645997..9f943d7 100644
--- a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper_service.py
+++ b/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper_service.py
@@ -27,7 +27,8 @@ from resource_management.libraries.functions import conf_select
 from resource_management.libraries.functions import stack_select
 from resource_management.libraries.functions import StackFeature
 from resource_management.libraries.functions.version import compare_versions, format_stack_version
-from resource_management.libraries.functions.stack_features import check_stack_feature 
+from resource_management.libraries.functions.stack_features import check_stack_feature
+from resource_management.libraries.functions.show_logs import show_logs
 
 @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
 def zookeeper_service(action='start', upgrade_type=None):
@@ -44,10 +45,15 @@ def zookeeper_service(action='start', upgrade_type=None):
   if action == 'start':
     daemon_cmd = format("source {config_dir}/zookeeper-env.sh ; {cmd} start")
     no_op_test = format("ls {zk_pid_file} >/dev/null 2>&1 && ps -p `cat {zk_pid_file}` >/dev/null 2>&1")
-    Execute(daemon_cmd,
-            not_if=no_op_test,
-            user=params.zk_user
-    )
+    
+    try:
+      Execute(daemon_cmd,
+              not_if=no_op_test,
+              user=params.zk_user
+      )
+    except:
+      show_logs(params.zk_log_dir, params.zk_user)
+      raise
 
     if params.security_enabled:
       kinit_cmd = format("{kinit_path_local} -kt {smoke_user_keytab} {smokeuser_principal};")
@@ -58,11 +64,14 @@ def zookeeper_service(action='start', upgrade_type=None):
 
   elif action == 'stop':
     daemon_cmd = format("source {config_dir}/zookeeper-env.sh ; {cmd} stop")
-    rm_pid = format("rm -f {zk_pid_file}")
-    Execute(daemon_cmd,
-            user=params.zk_user
-    )
-    Execute(rm_pid)
+    try:
+      Execute(daemon_cmd,
+              user=params.zk_user
+      )
+    except:
+      show_logs(params.zk_log_dir, params.zk_user)
+      raise
+    File(params.zk_pid_file, action="delete")
 
 @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
 def zookeeper_service(action='start', rolling_restart=False):

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/test/python/stacks/2.0.6/ZOOKEEPER/test_zookeeper_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/ZOOKEEPER/test_zookeeper_server.py b/ambari-server/src/test/python/stacks/2.0.6/ZOOKEEPER/test_zookeeper_server.py
index 1c20915..2bd9944 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/ZOOKEEPER/test_zookeeper_server.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/ZOOKEEPER/test_zookeeper_server.py
@@ -67,7 +67,9 @@ class TestZookeeperServer(RMFTestCase):
     self.assertResourceCalled('Execute', 'source /etc/zookeeper/conf/zookeeper-env.sh ; env ZOOCFGDIR=/etc/zookeeper/conf ZOOCFG=zoo.cfg /usr/lib/zookeeper/bin/zkServer.sh stop',
       user = 'zookeeper',
     )
-    self.assertResourceCalled('Execute', 'rm -f /var/run/zookeeper/zookeeper_server.pid')
+    self.assertResourceCalled('File', '/var/run/zookeeper/zookeeper_server.pid',
+        action = ['delete'],
+    )
     self.assertNoMoreResources()
 
   def test_configure_secured(self):
@@ -112,7 +114,9 @@ class TestZookeeperServer(RMFTestCase):
                   user = 'zookeeper',
     )
 
-    self.assertResourceCalled('Execute', 'rm -f /var/run/zookeeper/zookeeper_server.pid')
+    self.assertResourceCalled('File', '/var/run/zookeeper/zookeeper_server.pid',
+        action = ['delete'],
+    )
     self.assertNoMoreResources()
 
   def assert_configure_default(self):

http://git-wip-us.apache.org/repos/asf/ambari/blob/017fbf13/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py b/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
index ab5236b..e52f29c 100644
--- a/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
+++ b/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
@@ -148,5 +148,6 @@ class TestMetadataServer(RMFTestCase):
     self.assertResourceCalled('Execute', 'source /etc/atlas/conf/atlas-env.sh; /usr/hdp/current/atlas-server/bin/atlas_stop.py',
                               user = 'atlas',
     )
-    self.assertResourceCalled('Execute', 'rm -f /var/run/atlas/atlas.pid',
+    self.assertResourceCalled('File', '/var/run/atlas/atlas.pid',
+        action = ['delete'],
     )


Mime
View raw message