AMBARI-5186. On EC2, AMI for RHEL 5.7 does not start postgres on setup 
(aonishuk)


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

Branch: refs/heads/branch-1.5.0
Commit: 73b6b830fea04244f3f745e110ad689192a5ed9b
Parents: ea38fa3
Author: Andrew Onischuk <aonis...@hortonworks.com>
Authored: Mon Mar 24 08:43:42 2014 -0700
Committer: Andrew Onischuk <aonis...@hortonworks.com>
Committed: Mon Mar 24 08:43:42 2014 -0700

----------------------------------------------------------------------
 ambari-server/src/main/python/ambari-server.py  | 25 ++++++++++++--------
 .../src/test/python/TestAmbariServer.py         |  4 ++++
 2 files changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/73b6b830/ambari-server/src/main/python/ambari-server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari-server.py 
b/ambari-server/src/main/python/ambari-server.py
index 5cec271..97f405e 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -53,6 +53,7 @@ OS = OS.lower().strip()
 OS_UBUNTU = 'ubuntu'
 OS_FEDORA = 'fedora'
 OS_OPENSUSE = 'opensuse'
+OS_SUSE = 'suse'
 
 # action commands
 SETUP_ACTION = "setup"
@@ -1052,17 +1053,21 @@ def check_postgre_up():
         stdin=subprocess.PIPE,
         stderr=subprocess.PIPE
       )
-      time.sleep(20)
-      result = process.poll()
-      print_info_msg("Result of postgres start cmd: " + str(result))
-      if result is None:
-        process.kill()
-        pg_status = get_postgre_status()
-        if pg_status == PG_STATUS_RUNNING:
-          print_info_msg("Postgres process is running. Returning...")
-          return 0
+      if OS == OS_SUSE:
+        time.sleep(20)
+        result = process.poll()
+        print_info_msg("Result of postgres start cmd: " + str(result))
+        if result is None:
+          process.kill()
+          pg_status = get_postgre_status()
+        else:
+          retcode = result
       else:
-        retcode = result
+        out, err = process.communicate()
+        retcode = process.returncode
+      if pg_status == PG_STATUS_RUNNING:
+        print_info_msg("Postgres process is running. Returning...")
+        return 0
     except (Exception), e:
       pg_status = get_postgre_status()
       if pg_status == PG_STATUS_RUNNING:

http://git-wip-us.apache.org/repos/asf/ambari/blob/73b6b830/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py 
b/ambari-server/src/test/python/TestAmbariServer.py
index 54e4077..46c3e4c 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -29,6 +29,7 @@ import stat
 import datetime
 import operator
 import json
+import platform
 from pwd import getpwnam
 from ambari_server.resourceFilesKeeper import ResourceFilesKeeper, 
KeeperException
 
@@ -2019,11 +2020,14 @@ 
MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
                             popen_mock, sleep_mock):
     p = MagicMock()
     p.poll.return_value = 0
+    p.communicate.return_value = (None, None)
+    p.returncode = 0
     popen_mock.return_value = p
     run_os_command_mock.return_value = (0, None, None)
     rcode = ambari_server.check_postgre_up()
     self.assertEqual(0, rcode)
 
+    ambari_server.OS = 'suse'
     p.poll.return_value = 4
     get_postgre_status_mock.return_value = None
     rcode = ambari_server.check_postgre_up()

Reply via email to