metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmiklav...@apache.org
Subject metron git commit: METRON-1326: Metron deploy with Kerberos fails on Ambari 2.5 during ES service stop (mmiklavc via mmiklavc) closes apache/metron#894
Date Thu, 18 Jan 2018 19:22:31 GMT
Repository: metron
Updated Branches:
  refs/heads/master 7aa08aef1 -> 0df6678c8


METRON-1326: Metron deploy with Kerberos fails on Ambari 2.5 during ES service stop (mmiklavc
via mmiklavc) closes apache/metron#894


Project: http://git-wip-us.apache.org/repos/asf/metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/metron/commit/0df6678c
Tree: http://git-wip-us.apache.org/repos/asf/metron/tree/0df6678c
Diff: http://git-wip-us.apache.org/repos/asf/metron/diff/0df6678c

Branch: refs/heads/master
Commit: 0df6678c87b550fa2dcec81d0fef1af5a1c20a37
Parents: 7aa08ae
Author: mmiklavc <michael.miklavcic@gmail.com>
Authored: Thu Jan 18 12:22:16 2018 -0700
Committer: Michael Miklavcic <michael.miklavcic@gmail.com>
Committed: Thu Jan 18 12:22:16 2018 -0700

----------------------------------------------------------------------
 .../5.6.2/package/scripts/elastic_master.py     | 27 +++++++++++++++++--
 .../5.6.2/package/scripts/elastic_slave.py      | 28 +++++++++++++++++---
 .../5.6.2/package/scripts/kibana_master.py      | 24 ++++++++++++++++-
 3 files changed, 73 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metron/blob/0df6678c/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/ELASTICSEARCH/5.6.2/package/scripts/elastic_master.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/ELASTICSEARCH/5.6.2/package/scripts/elastic_master.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/ELASTICSEARCH/5.6.2/package/scripts/elastic_master.py
index c3f089a..3e299e7 100755
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/ELASTICSEARCH/5.6.2/package/scripts/elastic_master.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/ELASTICSEARCH/5.6.2/package/scripts/elastic_master.py
@@ -17,10 +17,13 @@ limitations under the License.
 
 """
 
+from resource_management.core import shell
 from resource_management.core.resources.system import Execute
 from resource_management.libraries.script import Script
 from resource_management.core.logger import Logger
 
+from resource_management.core.exceptions import ExecutionFailed
+from resource_management.core.exceptions import ComponentIsNotRunning
 from elastic import elastic
 
 
@@ -56,8 +59,28 @@ class Elasticsearch(Script):
         import params
         env.set_params(params)
         Logger.info('Check status of Elasticsearch master node')
-        status_cmd = "service elasticsearch status"
-        Execute(status_cmd)
+
+        # return codes defined by LSB
+        # http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html
+        cmd = ('service', 'elasticsearch', 'status')
+	
+        rc, out = shell.call(cmd, sudo=True, quiet=False)
+
+        if rc in [1, 2, 3]:
+          # if return code = 1, 2, or 3, then 'program is not running' or 'dead'
+          # Ambari's resource_management/libraries/script/script.py handles
+          # this specific exception as OK
+          Logger.info("Elasticsearch master is not running")
+          raise ComponentIsNotRunning()
+
+        elif rc == 0:
+          # if return code = 0, then 'program is running or service is OK'
+          Logger.info("Elasticsearch master is running")
+
+        else:
+          # else, program is dead or service state is unknown
+          err_msg = "Execution of '{0}' returned {1}".format(" ".join(cmd), rc)
+          raise ExecutionFailed(err_msg, rc, out)
 
     def restart(self, env):
         import params

http://git-wip-us.apache.org/repos/asf/metron/blob/0df6678c/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/ELASTICSEARCH/5.6.2/package/scripts/elastic_slave.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/ELASTICSEARCH/5.6.2/package/scripts/elastic_slave.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/ELASTICSEARCH/5.6.2/package/scripts/elastic_slave.py
index 8aaee75..d7684f0 100755
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/ELASTICSEARCH/5.6.2/package/scripts/elastic_slave.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/ELASTICSEARCH/5.6.2/package/scripts/elastic_slave.py
@@ -17,9 +17,12 @@ limitations under the License.
 
 """
 
+from resource_management.core import shell
+from resource_management.core.exceptions import ExecutionFailed
+from resource_management.core.exceptions import ComponentIsNotRunning
+from resource_management.core.logger import Logger
 from resource_management.core.resources.system import Execute
 from resource_management.libraries.script import Script
-from resource_management.core.logger import Logger
 
 from slave import slave
 
@@ -56,8 +59,27 @@ class Elasticsearch(Script):
         import params
         env.set_params(params)
         Logger.info('Check status of Elasticsearch data node')
-        status_cmd = "service elasticsearch status"
-        Execute(status_cmd)
+
+        # return codes defined by LSB
+        # http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html
+        cmd = ('service', 'elasticsearch', 'status')
+        rc, out = shell.call(cmd, sudo=True, quiet=False)
+
+        if rc in [1, 2, 3]:
+          # if return code = 1, 2, or 3, then 'program is not running' or 'dead'
+          # Ambari's resource_management/libraries/script/script.py handles
+          # this specific exception as OK
+          Logger.info("Elasticsearch slave is not running")
+          raise ComponentIsNotRunning()
+
+        elif rc == 0:
+          # if return code = 0, then 'program is running or service is OK'
+          Logger.info("Elasticsearch slave is running")
+
+        else:
+          # else, program is dead or service state is unknown
+          err_msg = "Execution of '{0}' returned {1}".format(" ".join(cmd), rc)
+          raise ExecutionFailed(err_msg, rc, out)
 
     def restart(self, env):
         import params

http://git-wip-us.apache.org/repos/asf/metron/blob/0df6678c/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/KIBANA/5.6.2/package/scripts/kibana_master.py
----------------------------------------------------------------------
diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/KIBANA/5.6.2/package/scripts/kibana_master.py
b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/KIBANA/5.6.2/package/scripts/kibana_master.py
index 4c001ef..861e19a 100755
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/KIBANA/5.6.2/package/scripts/kibana_master.py
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/KIBANA/5.6.2/package/scripts/kibana_master.py
@@ -23,6 +23,9 @@ import errno
 import os
 
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
+from resource_management.core import shell
+from resource_management.core.exceptions import ExecutionFailed
+from resource_management.core.exceptions import ComponentIsNotRunning
 from resource_management.core.logger import Logger
 from resource_management.core.resources.system import Directory
 from resource_management.core.resources.system import Execute
@@ -93,7 +96,26 @@ class Kibana(Script):
 
         Logger.info("Status of the Master")
 
-        Execute("service kibana status")
+        # return codes defined by LSB
+        # http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html
+        cmd = ('service', 'kibana', 'status')
+        rc, out = shell.call(cmd, sudo=True, quiet=False)
+
+        if rc in [1, 2, 3]:
+          # if return code = 1, 2, or 3, then 'program is not running' or 'dead'
+          # Ambari's resource_management/libraries/script/script.py handles
+          # this specific exception as OK
+          Logger.info("Kibana is not running")
+          raise ComponentIsNotRunning()
+
+        elif rc == 0:
+          # if return code = 0, then 'program is running or service is OK'
+          Logger.info("Kibana is running")
+
+        else:
+          # else, program is dead or service state is unknown
+          err_msg = "Execution of '{0}' returned {1}".format(" ".join(cmd), rc)
+          raise ExecutionFailed(err_msg, rc, out)
 
     @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
     def load_template(self, env):


Mime
View raw message