ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject git commit: AMBARI-6596. Flume: add support for 'run-as' user (ncole)
Date Thu, 24 Jul 2014 23:55:19 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk be9e0b8cb -> 0fc60a40b


AMBARI-6596. Flume: add support for 'run-as' user (ncole)


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

Branch: refs/heads/trunk
Commit: 0fc60a40b4d34d4facc0d3888423ce1bd7ecdf10
Parents: be9e0b8
Author: Nate Cole <ncole@hortonworks.com>
Authored: Thu Jul 24 10:29:04 2014 -0400
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Thu Jul 24 19:54:30 2014 -0400

----------------------------------------------------------------------
 .../services/FLUME/configuration/flume-env.xml  |  5 ++++
 .../services/FLUME/package/scripts/flume.py     | 12 +++-----
 .../services/FLUME/package/scripts/params.py    |  3 ++
 .../python/stacks/2.0.6/FLUME/test_flume.py     | 30 ++++++++++----------
 4 files changed, 27 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc60a40/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-env.xml
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-env.xml
index 7107248..43cea5f 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-env.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-env.xml
@@ -31,4 +31,9 @@
     <value>/var/log/flume</value>
     <description>Location to save log files</description>
   </property>
+  <property>
+    <name>flume_user</name>
+    <value>flume</value>
+    <description>Flume User</description>
+  </property>
 </configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc60a40/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume.py
index 5aa768a..1cbdf39 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume.py
@@ -58,11 +58,8 @@ def flume(action = None):
         mode = 0644)
 
   elif action == 'start':
-    flume_base = format('env JAVA_HOME={java_home} /usr/bin/flume-ng agent '
-      '--name {{0}} '
-      '--conf {{1}} '
-      '--conf-file {{2}} '
-      '{{3}}')
+    flume_base = format('su -s /bin/bash {flume_user} -c "export JAVA_HOME={java_home}; '
+      '/usr/bin/flume-ng agent --name {{0}} --conf {{1}} --conf-file {{2}} {{3}}"')
 
     for agent in cmd_target_names():
       flume_agent_conf_dir = params.flume_conf_dir + os.sep + agent
@@ -85,9 +82,8 @@ def flume(action = None):
         Execute(flume_cmd, wait_for_finish=False)
 
         # sometimes startup spawns a couple of threads - so only the first line may count
-        pid_cmd = format('pgrep -o -f {flume_agent_conf_file} > {flume_agent_pid_file}')
-
-        Execute(pid_cmd, logoutput=True, tries=5, try_sleep=10)
+        pid_cmd = format('pgrep -o -u {flume_user} -f ^{java_home} > {flume_agent_pid_file}')
+        Execute(pid_cmd, logoutput=True, tries=10, try_sleep=1)
 
     pass
   elif action == 'stop':

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc60a40/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/params.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/params.py
index 64ee2f1..e26b74d 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/params.py
@@ -34,6 +34,9 @@ flume_run_dir = '/var/run/flume'
 flume_user = 'flume'
 flume_group = 'flume'
 
+if 'flume-env' in config['configurations'] and 'flume_user' in config['configurations']['flume-env']:
+  flume_user = config['configurations']['flume-env']['flume_user']
+
 if (('flume-conf' in config['configurations']) and('content' in config['configurations']['flume-conf'])):
   flume_conf_content = config['configurations']['flume-conf']['content']
 else:

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc60a40/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
index 8c87813..1abd849 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
@@ -49,18 +49,18 @@ class TestFlumeHandler(RMFTestCase):
 
     self.assert_configure_default()
 
-    self.assertResourceCalled('Execute', format('env JAVA_HOME=/usr/jdk64/jdk1.7.0_45 /usr/bin/flume-ng
agent '
+    self.assertResourceCalled('Execute', format('su -s /bin/bash flume -c "export JAVA_HOME=/usr/jdk64/jdk1.7.0_45;
/usr/bin/flume-ng agent '
       '--name a1 '
       '--conf /etc/flume/conf/a1 '
       '--conf-file /etc/flume/conf/a1/flume.conf '
       '-Dflume.monitoring.type=ganglia '
-      '-Dflume.monitoring.hosts=c6401.ambari.apache.org:8655'),
+      '-Dflume.monitoring.hosts=c6401.ambari.apache.org:8655"'),
       wait_for_finish = False)
 
-    self.assertResourceCalled('Execute', 'pgrep -o -f /etc/flume/conf/a1/flume.conf >
/var/run/flume/a1.pid',
+    self.assertResourceCalled('Execute', 'pgrep -o -u flume -f ^/usr/jdk64/jdk1.7.0_45 >
/var/run/flume/a1.pid',
       logoutput = True,
-      tries = 5,
-      try_sleep = 10)
+      tries = 10,
+      try_sleep = 1)
 
     self.assertNoMoreResources()
 
@@ -197,18 +197,18 @@ class TestFlumeHandler(RMFTestCase):
 
     self.assert_configure_many()
 
-    self.assertResourceCalled('Execute', format('env JAVA_HOME=/usr/jdk64/jdk1.7.0_45 /usr/bin/flume-ng
agent '
+    self.assertResourceCalled('Execute', format('su -s /bin/bash flume -c "export JAVA_HOME=/usr/jdk64/jdk1.7.0_45;
/usr/bin/flume-ng agent '
       '--name b1 '
       '--conf /etc/flume/conf/b1 '
       '--conf-file /etc/flume/conf/b1/flume.conf '
       '-Dflume.monitoring.type=ganglia '
-      '-Dflume.monitoring.hosts=c6401.ambari.apache.org:8655'),
+      '-Dflume.monitoring.hosts=c6401.ambari.apache.org:8655"'),
       wait_for_finish = False)
 
-    self.assertResourceCalled('Execute', 'pgrep -o -f /etc/flume/conf/b1/flume.conf >
/var/run/flume/b1.pid',
+    self.assertResourceCalled('Execute', 'pgrep -o -u flume -f ^/usr/jdk64/jdk1.7.0_45 >
/var/run/flume/b1.pid',
       logoutput = True,
-      tries = 5,
-      try_sleep = 10)
+      tries = 10,
+      try_sleep = 1)
 
     self.assertNoMoreResources()
 
@@ -225,18 +225,18 @@ class TestFlumeHandler(RMFTestCase):
 
     self.assert_configure_many()
 
-    self.assertResourceCalled('Execute', format('env JAVA_HOME=/usr/jdk64/jdk1.7.0_45 /usr/bin/flume-ng
agent '
+    self.assertResourceCalled('Execute', format('su -s /bin/bash flume -c "export JAVA_HOME=/usr/jdk64/jdk1.7.0_45;
/usr/bin/flume-ng agent '
       '--name b1 '
       '--conf /etc/flume/conf/b1 '
       '--conf-file /etc/flume/conf/b1/flume.conf '
       '-Dflume.monitoring.type=ganglia '
-      '-Dflume.monitoring.hosts=c6401.ambari.apache.org:8655'),
+      '-Dflume.monitoring.hosts=c6401.ambari.apache.org:8655"'),
       wait_for_finish = False)
 
-    self.assertResourceCalled('Execute', 'pgrep -o -f /etc/flume/conf/b1/flume.conf >
/var/run/flume/b1.pid',
+    self.assertResourceCalled('Execute', 'pgrep -o -u flume -f ^/usr/jdk64/jdk1.7.0_45 >
/var/run/flume/b1.pid',
       logoutput = True,
-      tries = 5,
-      try_sleep = 10)
+      tries = 10,
+      try_sleep = 1)
 
     self.assertNoMoreResources()
 


Mime
View raw message