ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject ambari git commit: AMBARI-11174. Modify rolling upgrade process to support both ranger admin HA and ranger-kms components. (Selvamohan Neethiraj via yusaku)
Date Mon, 18 May 2015 22:57:58 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 2932476fb -> 7fba25315


AMBARI-11174. Modify rolling upgrade process to support both ranger admin HA and ranger-kms
components. (Selvamohan Neethiraj via yusaku)


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

Branch: refs/heads/trunk
Commit: 7fba253156e6899ebc46bb9fdcb2cbfe2a079e47
Parents: 2932476
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Mon May 18 15:57:17 2015 -0700
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Mon May 18 15:57:17 2015 -0700

----------------------------------------------------------------------
 .../0.4.0/package/scripts/ranger_admin.py       | 34 ++++++++++++++++++--
 .../0.4.0/package/scripts/service_check.py      | 15 ++++++---
 .../0.5.0.2.3/package/scripts/kms_server.py     |  5 +++
 .../stacks/HDP/2.3/upgrades/upgrade-2.3.xml     | 21 +++++++++++-
 4 files changed, 68 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7fba2531/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py
b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py
index f56f860..40717f8 100644
--- a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py
+++ b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py
@@ -25,9 +25,12 @@ from resource_management.core.logger import Logger
 from resource_management.core import shell
 from ranger_service import ranger_service
 import upgrade
+import os, errno
 
 class RangerAdmin(Script):
 
+  upgrade_marker_file = '/tmp/rangeradmin_ru.inprogress'
+
   def get_stack_to_component(self):
     return {"HDP": "ranger-admin"}
 
@@ -51,11 +54,17 @@ class RangerAdmin(Script):
     env.set_params(params)
     Execute(format('{params.ranger_stop}'), user=params.unix_user)
 
+
   def pre_rolling_restart(self, env):
     import params
     env.set_params(params)
+    self.set_ru_rangeradmin_in_progress()
     upgrade.prestart(env, "ranger-admin")
 
+  def post_rolling_restart(self,env):
+     if os.path.isfile(RangerAdmin.upgrade_marker_file):
+        os.remove(RangerAdmin.upgrade_marker_file) 
+
   def start(self, env, rolling_restart=False):
     import params
     env.set_params(params)
@@ -68,8 +77,11 @@ class RangerAdmin(Script):
     code, output = shell.call(cmd, timeout=20)
 
     if code != 0:
-      Logger.debug('Ranger admin process not running')
-      raise ComponentIsNotRunning()
+      if self.is_ru_rangeradmin_in_progress():
+         Logger.info('Ranger admin process not running - skipping as rolling upgrade is in
progress')
+      else:
+         Logger.debug('Ranger admin process not running')
+         raise ComponentIsNotRunning()
     pass
 
   def configure(self, env):
@@ -82,6 +94,24 @@ class RangerAdmin(Script):
 
     ranger('ranger_admin')
 
+  def set_ru_rangeradmin_in_progress(self):
+    config_dir = os.path.dirname(RangerAdmin.upgrade_marker_file)
+    try:
+       msg = "Starting RU"
+       if (not os.path.exists(config_dir)):
+          os.makedirs(config_dir)
+       ofp = open(RangerAdmin.upgrade_marker_file, 'w')
+       ofp.write(msg)
+       ofp.close()
+    except OSError as exc:
+       if exc.errno == errno.EEXIST and os.path.isdir(config_dir): 
+          pass
+       else:
+          raise
+
+  def is_ru_rangeradmin_in_progress(self):
+    return os.path.isfile(RangerAdmin.upgrade_marker_file)
 
 if __name__ == "__main__":
   RangerAdmin().execute()
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/7fba2531/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/service_check.py
b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/service_check.py
index 69f955f..70884f6 100644
--- a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/service_check.py
+++ b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/service_check.py
@@ -18,9 +18,13 @@ limitations under the License.
 """
 
 from resource_management import *
+import os
 
 
 class RangerServiceCheck(Script):
+
+  upgrade_marker_file = '/tmp/rangeradmin_ru.inprogress'
+
   def service_check(self, env):
     import params
 
@@ -34,9 +38,11 @@ class RangerServiceCheck(Script):
     if code == 0:
       Logger.info('Ranger admin process up and running')
     else:
-      Logger.debug('Ranger admin process not running')
-      raise ComponentIsNotRunning()
-
+      if (self.is_ru_rangeradmin_in_progress()):
+         Logger.info('Ranger admin process not running - skipping as rolling upgrade is in
progress')
+      else
+         Logger.debug('Ranger admin process not running')
+         raise ComponentIsNotRunning()
   pass
 
 
@@ -48,9 +54,10 @@ class RangerServiceCheck(Script):
     else:
       Logger.debug('Ranger usersync process not running')
       raise ComponentIsNotRunning()
-
   pass
 
+  def is_ru_rangeradmin_in_progress(self):
+    return os.path.isfile(RangerServiceCheck.upgrade_marker_file)
 
 if __name__ == "__main__":
   RangerServiceCheck().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/7fba2531/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms_server.py
b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms_server.py
index a8aa9c7..b6020ff 100644
--- a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms_server.py
+++ b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms_server.py
@@ -54,5 +54,10 @@ class KmsServer(Script):
     env.set_params(params)
     kms()
 
+  def pre_rolling_restart(self, env):
+    import params
+    env.set_params(params)
+    upgrade.prestart(env, "ranger-kms-server")
+
 if __name__ == "__main__":
   KmsServer().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/7fba2531/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
index be9cc14..b472c5f 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
@@ -50,7 +50,11 @@
         </task>
       </execute-stage>
 
-      <execute-stage service="RANGER" component="RANGER_ADMIN" title="Pre Upgrade Ranger">
+      <execute-stage service="RANGER" component="RANGER_ADMIN" title="Pre Upgrade Ranger
Admin">
+        <task xsi:type="execute" hosts="master">
+            <script>scripts/ranger_admin.py</script>
+            <function>pre_rolling_restart</function>
+        </task>
         <task xsi:type="manual">
           <message>Before continuing, please backup the Ranger Admin database and Ranger
Audit database</message>
         </task>
@@ -72,6 +76,13 @@
       </service>
     </group>
 
+    <group name="RANGER_KMS" title="Ranger_KMS">
+      <skippable>true</skippable>
+      <service name="RANGER_KMS">
+        <component>RANGER_KMS_SERVER</component>
+      </service>
+    </group>
+
     <group name="CORE_MASTER" title="Core Masters">
       <service-check>false</service-check>
       <service name="HDFS">
@@ -324,6 +335,14 @@
       </component>
     </service>
 
+    <service name="RANGER_KMS">
+      <component name="RANGER_KMS_SERVER">
+        <upgrade>
+          <task xsi:type="restart" />
+        </upgrade>
+      </component>
+    </service>
+
     <service name="HDFS">
       <component name="NAMENODE">
         <upgrade>


Mime
View raw message